Install Ghost on your VPS

The recipe I followed to install Ghost on a self hosted VPS.

Install Ghost on your VPS
Photo by Ryan Millsap / Unsplash

I decided that I wanted to self host my Ghost installation. I chose HostAfrica (affiliate link) to host my VPS. I found their pricing very reasonable.

With that part done we can get down to the installation. The instructions below should work for any installation of Ubuntu 20.04. Once you have your VPS up and booted we will move on to the actual installation of Ghost and its requirements.

Required Software

The first thing to do is ensure that we have all the required software in order to get Ghost installed and working correctly.

We start with Nginx.

$ sudo apt install nginx

Not much explanation needed here. After Nginx is installed we need to make sure that our firewall (ufw) is not blocking it.

$ sudo ufw allow 'Nginx Full'

'Nginx Full' could be replaced with 'Nginx HTTP' or 'Nginx HTTPS' depending on your needs.

The next piece of the puzzle is MySQL. This one is a little more complex.

$ sudo apt install mysql-server

The slightly higher complexity due to the additional configuration required. We need to ensure that our 'root' user is able to access MySQL so that when we install Ghost it is capable of configuring our database and database user we need.

$ sudo mysql

This should take you into the MySQL console. Once inside we will need to connect to the 'mysql' database and alter the 'user' table.

mysql> connect mysql;
mysql> ALTER TABLE user 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'super_Secr3t-passw0rd';

Naturally you will replace 'super_Secr3t_passw0rd' with the actual password you want to use.

Next is NodeJS. For this we need to adjust our apt sources. Fortunately, there is a fairly simple way to do this. We will download a script and run it. The script basically adds the needed repositories and runs 'apt update'.

$ curl -sL | sudo -E bash

Once this has completed, we need to install nodejs.

$ sudo apt install nodejs

That brings us to the end of the required software. Lets move on to the Ghost specific part of our installation.

Ghost Installation

The Ghost installation is made up of two parts. First we need to install ghost-cli. This tool will be used later to install the actual ghost our readers will see.

$ sudo npm install ghost-cli@latest -g

A few more preparatory steps:

$ sudo mkdir /var/www/site_name
$ sudo chown user:group /var/www/site_name
$ cd /var/www/site_name

Replace site_name with something more appropriate to your setup. Once this is done we can go ahead and use it to install. Also replace 'user:group' with the correct details for your server.

$ ghost install

This process will ask a few questions. Answer them appropriately to suit your circumstances.

If all went well you should now have a working copy of ghost. You may now begin configuration of your site.

Add awesome content and engage your readers.