How to install Ghost CMS on your Ubuntu 16.04 VPS

Ghost is a modern, open source blogging platform written in NodeJS.

Ghost is a modern, open source blogging platform written in NodeJS. Unlike WordPress, Ghost is purely a blogging platform, and it is meant to be used only for a blog, not something more expansive like an e-commerce website. The most popular features of Ghost is that it is simple, elegant and responsive in design. The latest release of Ghost CMS 1.10+ comes with a brand new Markdown editor, a refreshed UI, a new default theme design, and a lot more features that make for a nicer blogging experiencing.

For installing on production, Ghost officially recommends the following stack and server setup:

  • Ubuntu 16.04
  • MySQL
  • NGINX
  • Systemd
  • NodeJS
  • At least 1GB memory
  • A non-root user for running ghost commands

Source: Ghost

Prerequisites

  • A VPS running Ubuntu 16.04.
  • A non-root, sudo-enabled user. If you only have a root user, see our SSH tutorial for details on creating new users.
  • A registered domain name.
  • A DNS A record that points to your server’s IP address based on the FQDN you want to use. For example, an A record named test would point to test.DOMAIN.TLD.

You’re being overcharged for your cloud computing.

We fixed that. For a limited time, during our 7-year anniversary sale, save $2,592 with a 16GB RAM server. Deploy with honest value from your cloud hosting provider. ⚡

Notes

  • This tutorial requires the use of domain names. Whenever you see either the SUBDOMAIN, DOMAIN, or TLD variables, replace them with the details of your domain name. In example.ssdnodes.com, example is the SUBDOMAIN, ssdnodes is the DOMAIN, and .com is the TLD.
  • This tutorial requires the use of passwords. Whenever you see the PASSWORD variable, then replace it with your own.

Getting your server ready for Ghost CMS

Ghost is built on NodeJS, and the latest release of Ghost 1.0 supports NodeJS versions 8.9+ and 6.9+ only. You can pick either of the NodeJS versions, but for this tutorial, we will use NodeJS version 8. To install it, add the NodeSource APT repository to your server first.

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

Now install NodeJS with the following apt-get command:

$ sudo apt-get install nodejs

Check the version of Node and NPM:

$ node -v && npm -v
v8.11.3
5.6.0

Install MariaDB and create a database

Ghost supports either MySQL/MariaDB or SQLite databases. However, for this tutorial, we will be using the MariaDB database. You can also opt for MySQL instead of MariaDB.

Install the latest stable release of MariaDB server on your system by using following apt-get command:

$ sudo apt-get install mariadb-server

Next, run mysql_secure_installation to configure a few settings of MariaDB like updating the root password, removing the test database, and more, to make it secure.

$ sudo mysql_secure_installation

Once the MariaDB server is installed and configured in your server, create a user and a database especially for Ghost. To do that, log in to the MariaDB server using mysql -u root -p command and complete the steps as described below.

$ mysql -u root -p
Enter password:

MariaDB [mysql]> CREATE DATABASE blog;
Query OK, 1 row affected (0.00 sec)

MariaDB [mysql]> CREATE USER 'ghostuser'@'localhost' IDENTIFIED BY 'PASSWORD';
Query OK, 0 rows affected (0.00 sec)

MariaDB [mysql]> GRANT ALL ON blog.* TO 'ghostuser'@'localhost' IDENTIFIED BY 'PASSWORD' WITH GRANT OPTION;
Query OK, 0 rows affected (0.00 sec)

MariaDB [mysql]> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

MariaDB [mysql]> exit

Install Nginx

Ghost runs on port 2368, which is different from standard web server port 80 typically employed by either Apache or Nginx. To direct traffic to Ghost, you need to configure a proxy server that will act as a front end. Ghost officially recommends Nginx as a proxy server, although you can use Apache to do the same job. To install Nginx, issue the following command from the terminal:

$ sudo apt-get install nginx
 $ sudo systemctl enable nginx

Install Ghost-CLI

Ghost-CLI is a command line interface (CLI) tool to install and update Ghost in the terminal. Ghost-CLI makes it easy to install Ghost by selecting the database, configuring NGINX as a reverse proxy, setting up a Let’s Encrypt SSL certificate, and creating a systemd service with a single command.

The objective of the Ghost CLI project is to make setting up and maintaining a Ghost site as straightforward as possible for people who do not want to use Ghost(Pro). Source: Ghost-CLI

Since Ghost-CLI is an NPM module, it can be installed using either npm or yarn. We will use npm to install it.

$ sudo npm install -g [email protected]

Check the version of Ghost-CLI using following command:

$ ghost -v
Ghost-CLI version: 1.8.1

Install Ghost

To install Ghost, navigate to the /var/www/html and create a folder for it.

$ cd /var/www/html
$ sudo mkdir -p /var/www/html/blog

Note: Installing Ghost in the /root or /home/USER folder won’t work and result in a broken setup! Please only use /var/www/html because it has the right permissions.

Once you’re done with creating the installation folder for Ghost, change the ownership of the folder to a non-root, sudo-enabled user. The installation of Ghost will not proceed if the ownership of the newly created folder remains with root user. For this tutorial, we have created a non-root, sudo-enabled user by the name bloguser.

Note: Don’t give this new user the name ghost! Ghost-CLI will create a ghost user for managing the blog during installation.

$ sudo chown bloguser:bloguser /var/www/html/blog

Next, assign correct permissions to the installation folder.

$ sudo chmod 775 /var/www/html/blog

Change to the shell of the non-root user and subsequently navigate to the Ghost installation folder /var/www/html/blog to install it.

$ su - bloguser
$ [email protected]: cd /var/www/html/blog/

Now install Ghost using Ghost-CLI. Answer the prompts as followed:

? Enter your blog URL: https://DOMAIN.TLD
? Enter your MySQL hostname: localhost
? Enter your MySQL username: ghostuser
? Enter your MySQL password: PASSWORD
? Enter your Ghost database name: blog
? Do you wish to set up "ghost" mysql user? no
? Do you wish to set up Nginx? yes
? Do you wish to set up SSL? yes
? Enter your email (used for Let's Encrypt notifications) [email protected]
? Do you wish to set up Systemd? yes
? Do you want to start Ghost? yes

Your Ghost installation should be finished at this point! You can now access it via https://DOMAIN.TLD or https://SUBDOMAIN.DOMAIN.TLD, depending on your particular configuration.

Complete the Ghost CMS setup

To complete the setup process, point your browser to the Ghost CMS configuration page at https://DOMAIN.TLD/ghost.

STEP 1

Click Create your account.

STEP 2

Fill up all the details, like the blog’s title, your name, email address, and password. The email address and password will be used by Ghost to authenticate the admin user at later stages. Once done click Invite your team to add more members to your team.

STEP 3

Or, click the I’ll do this later, take me to my blog! link to visit the admin section and change your site’s theme or configure additional settings.

The setup of Ghost CMS is complete!

You can now start blogging with this awesome platform. Consult the official documentation for theming instructions and other configurations.

 

Subscribe to our newsletter
Sign up here to get the latest news, updates and special offers delivered directly to your inbox.
You can unsubscribe at any time

Leave A Reply

Your email address will not be published.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More