In this tutorial you will learn how to setup and self-host ghost on your server.
Login to your server as root via ssh, and create a new user.
ssh [email protected]
Add the new user to the supergroup user.
usermod -aG sudo username
Now log in with the new user.
su - username
Once you are logged in via the new user, run the following commands to update the system.
sudo apt-get update sudo apt-get upgrade
Ghost uses nginx, run the following command to install nginx.
sudo apt-get install nginx
If ufw firewall is enabled on your server, make sure it’s not blocking HTTP/HTTPS connection.
sudo ufw allow 'Nginx Full'
sudo apt-get install mysql-server
During the installation of MySQL, you will be asked to choose a password for the root user. Set a password you want and press enter.
Once the MySQL server is installed, install node.js via the following commands.
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash sudo apt-get install -y nodejs
Install Ghost-CLI, the command line tool that you can use to manage and setup ghost on your server.
sudo npm install [email protected] -g
In this step you need to create the directory where ghost will be installed, and to make sure that the user has the right permission to install ghost.
Create The Directory
The command below will create the directory where you want ghost installed. You can name the directory anything you want.
sudo mkdir -p /var/www/ghost
Give the directory another name, In cases when you are self-hosting more than one ghost instances on your server.
sudo mkdir -p /var/www/domain.com
Set up permission for the user that will own this directory. By running the following command below, you are giving permissions to that user for managing ghost. To do that, simply replace user:user with the username of the user you created in the step 1.
sudo chown user:user /var/www/ghost
Make sure the user has the correct permission.
sudo chmod 775 /var/www/ghost
Navigate to the ghost directory.
Then run the following command for installing Ghost.
During the installation process, ghost-cli will need the following information:
1. Blog url
Set the correct blog url, url should start with either: http:// or https://
2. MySQL Hostname
Leave the hostname as is “localhost” if the mysql server is installed on the same server.
3. MySQL Username and Password
Username is root
Password is the same password you created during the installation of MySQL server.
4. Ghost Database Name
Set the database name, and press enter.
Once you are done with the steps above, answer with “Yes” to the following questions :
Set up a ghost MySQL user? Yes
Set up NGINX? Yes
Set up SSL? Yes
If you answer yes to SSL you will need to provide your email address, that email address will be used to manage/renew your ssl certificate. Set the email address, and press enter to continue.
Set up systemd? Yes
Start GHOST? Yes
Now that ghost is installed, here are some useful commands that you will need to know to manage ghost easily.
To manage ghost, you need to login to the user that owns the ghost directory, not via root user.
To get the full list of available commands, type
In this tutorial, you learned step by step how to install manually, and self-host ghost on your server. Personally i like to have total control over my server, that’s why i prefer the manual way. However, this it’s not the only way to install ghost, some hosting companies(Including Ghost Itself with Ghost Pro) offer ghost as a one click installer, that allows you to install ghost via one click.