Ghost CMS: How to install on your Ubuntu 16.04 VPS
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
- At least 1GB memory
- A non-root user for running
- A VPS running Ubuntu 16.04.
- A non-root,
sudo-enableduser. If you only have a
rootuser, 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
testwould point to
Celebrate 8 years of SSD hosting with incredible deals!
We can’t believe it, but it’s been 8 years since we here at SSD Nodes launched our all-SSD VPS cloud. To celebrate, we’re offering amazing deals on all of our most popular plans– like a 16GB RAM SSD VPS loaded with resources for as little as $7.99/month!
- This tutorial requires the use of domain names. Whenever you see either the
TLDvariables, replace them with the details of your domain name. In
- This tutorial requires the use of passwords. Whenever you see the
PASSWORDvariable, then replace it with your own.
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
$ sudo apt-get install nodejs
Check the version of Node and NPM:
$ node -v && npm -v v8.11.3 5.6.0
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
$ sudo apt-get install mariadb-server
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
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
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
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
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
/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. Check this tutorial to create a non-root, sudo-enabled user.
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://SUBDOMAIN.DOMAIN.TLD, depending on your particular configuration.
To complete the setup process, point your browser to the Ghost CMS configuration page at
Create your account.
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.
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.