How to Install Ghost CMS on a Hetzner Cloud Server

Hetzner is one of the cheapest and reliable Cloud VPS Provider we work with. If you are looking for a Cheap Ghost Server, Hetzner may be one of the good choice that you may make. Their Cloud VPS Servers starts at €2.49/Month. Plus, you get a choice of different Operating Systems of Ubuntu, CentOS, Fedora and Debian.

For this tutorial, we are using the Cheapest Option available, i.e., the €2.49/Month plan with Ubuntu Operating System. If you are ready, go ahead and create a Cloud VPS at Hetzner. The root credentials will be emailed to your registered email address by Hetzner.

Once you have created the server, keep a domain name or sub-domain handy. In the following step we will explain the full configuration for Ubuntu and Ghost on a Hetzner Cloud VPS.

For this demonstration, we will be using demo.technikal.net as the domain for Ghost. We will be installing Ghost CLI Version 6.13.0 and will use the same to install Ghost on the cloud server.

Step 1: Login to SSH as root & change the credentials.

Okay, so we assume now you have the root credentials ready for your newly created Cloud VPS. Open the Terminal Application on your Mac or PowerShell on Windows 10 and login to ssh using the following command to your server.

ssh root@<your_server_IP>

The system will first ask whether you want to continue with the ssh connection since it's not able to verify the authenticity of the server. Don't worry about that, go ahead and type yes & press the return key.

The system will ask you to change the password, you need to enter the current root password, following by a new password twice. Please do that and proceed to the next step.

Step 2: Create a new user using the terminal

Run the following command with an user name. Please do not use ghost as an username, that conflicts with ghost CLI.

adduser <your_new_username>

Once you run that command, the system will ask for a new password for the new user. You need to type that twice. Later, it will ask for user's personal details, you can either give those or press return key to skip. Once done, you need to add the user to superuser group to unlock the admin privileges. To do so, please run the following commands.

usermod -aG sudo <your_new_username>

Once you have successfully run the previous command, login using your newly created user by running the following command.

su - <your_new_username>

Step 3: Update packages & Install NGINX

To ensure the package lists and installed packages are up to date, please run the following commands.

sudo apt-get update

Running the above command will ask you the password of the newly created user, please type that and hit the return key. Once the update process is done, run the next command to update the packages. It may ask you whether you want to continue or not, press y to continue.

sudo apt-get upgrade

Okay, now that updates and upgrades are done, it's time to install nginx on the Ubuntu VPS. To do so, please run the following command. Again it will ask whether you want to continue or not, press y to continue with the installation.

sudo apt-get install nginx

Once the NGINX installation is done, please run the following command to allow HTTP & HTTPS connections through the firewall.

sudo ufw allow 'Nginx Full'

Step 4: Install MySQL & Node.JS on Ubuntu

So far we have done the basic server setup. Now we need to install the MySQL Server so that Ghost can use the MySQL Database System as well as, we will install Node.JS since Ghost is built using Node.JS.

To install MySQL, run the following command:

sudo apt-get install mysql-server

During the installation you need to create a Password and repeat the same & keep a note of the password, we are going to need it on the next step. Please do not skip the password creation part.

Once the installation is done, login to MySQL using the following command:

sudo mysql -p

It will ask you for the password, please enter the password you just created during the MySQL installation. Now you need to update your user with this password, Replace 'your_password' with your password, but keep the quote marks and run the following command:

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'your_password';

Once this is done, run quit to quit the MySQL.

It's time to install Node.JS on the server. To do so, please run the following command:

curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash

and

sudo apt-get install -y nodejs

Step 5: Install Ghost CLI

Now that NGINX, MySQL and Node.JS are installed on the server, it's time to install the Ghost CLI and then proceed with the final step of configuring a domain on the server. To install the Ghost CLI, please run the following command:

sudo npm install ghost-cli@latest -g

Step 6: Install Ghost CMS on a domain

Once the Ghost CLI is installed, we can now install Ghost on a domain. Before doing so, please make sure your domain points to your server's IP address. So for example, if your server's IP address is 192.168.0.1 then you should create the following A Record at your Domain Registrar's DNS Management section.

Record Type: A
Name: @
IP or Content: 192.168.0.1
TTL: Auto

In our case, we will be using demo.technikal.net, so we are creating the following A Record at our domain registrar. You can use Cloudflare, they provides a very easy to handle DNS Management for Free.

Record Type: A
Name: demo
IP or Content: 192.168.0.1
TTL: Auto

We are using the Name as demo because we are using a subdomain instead of the main domain. Okay, now that the domain is pointed to the server, let's create the domain's root directory within our server. To do so, we need run the following command:

sudo mkdir -p /var/www/domains_directory_name

Now we need to update the ownership of the directory to your created ssh user from Step 2. To do so, please run the following command.

sudo chown <your_new_username>:<your_new_username> /var/www/ghost

Now we need to update the directory with the correct permissions. Please run the following command:

sudo chmod 775 /var/www/domains_directory_name

Once done, let's navigate to the directory using the following command:

cd /var/www/domains_directory_name

Alright, now the final command to install and run Ghost for the domain demo.technikal.net. Please run the following command after navigating the directory.

ghost install

It will ask for the blog URL, followed by MySQL hostname, username, password.
Pleae enter the domain's name with HTTPS instead of HTTP. So in our case, the blog URL is https://demo.technikal.net. Here is the list of the answers you need to use during the installation.

Enter your MySQL hostname: localhost
Enter your MySQL username: root
Enter your MySQL password: Your MySQL Password Created on Step 4.
Do you wish to set up "ghost" mysql user?: Yes
Do you wish to set up Nginx? Yes
Do you wish to set up SSL? Yes
Enter your email (For SSL Certificate): Your Email ID
Do you wish to set up Systemd? Yes
Do you want to start Ghost? Yes

If everything is okay, you should see the following success message:

Ghost was installed successfully! To complete setup of your publication, visit:
https://your_domain_name/ghost/

All you need to do is open that URL and set the Ghost Password.

Yay! You have successfully installed Ghost on a Hetzner Cloud VPS. You can add more domain by following the Step 6. You can host multiple Ghost Installation on a signle server.
Note: You can use this tutorial for installing Ghost on any Ubuntu Server.
For more technical details about this installation process, please read Ghost's Official Documentation.

Please let us know if you have any questions in the comments below.
Thanks!