Install and Configure a Ghost v1.0.0 Blog on Ubuntu 16.04
Ghost is a modern, open source publishing platform built on Node.js with an Ember.js admin client, a JSON API, and a theme API powered by Handlebars.js. Ghost team recently released a new version of Ghost with a lot of new features and improvements: new markdown editor with the toolbar to help you with styling your post, UI/UX improvements, drag and drop multiple images, improved installation and update process with new tool called Ghost-CLI, new default theme Casper v2.0.0 and much more. I leave it to you to explore more after you install it.
In this tutorial we are going to install, setup and configure a Ghost v1.0.0 on Ubuntu 16.04 LTS using MySQL, Let's Encrypt, Node.js, NPM, Ghost-CLI and NGINX.
NOTE: Ubuntu 16.04 LTS is the only officially supported Linux distribution. It is not possible to install Ghost v1.0.0 on other Linux distributions. In future, it will probably be possible to install it when they add support for other distributions in Ghost-CLI tool.
Recommended system stack for production installs
Ghost team recommends the following server stack and setup for production installation of Ghost v1.0.0 blog:
- Ubuntu 16.04 as the operating system with minimum 1GB of RAM (swap can be used)
- Systemd (to manage the Ghost process)
- MySQL as the recommended database engine
- NGINX (minimum of 1.9.5 for SSL)
- Node.js v6 installed via NodeSource repository
- NPM or Yarn package manager
- C++ compiler
- A non-root user for running
Before you Begin
Check Ubuntu version:
lsb_release -ds # Ubuntu 16.04.3 LTS
Create a new non-root user account with
sudoaccess and switch to it:
johndoewith your username
adduser johndoe --gecos "John Doe" usermod -aG sudo johndoe su - johndoe
Set up the timezone:
sudo dpkg-reconfigure tzdata
Ensure that your system is up to date:
sudo apt update && sudo apt upgrade -y
sudo apt install -y build-essential
Step 1 - Install MySQL
First, we will need to install MySQL database as Ghost recommends it as database for production environment.
Download and install MySQL:
sudo apt install -y mysql-server
NOTE: You will be prompted to enter password for the MySQL "root" user. Enter strong password!
Check MySQL version:
mysql --version # mysql Ver 14.14 Distrib 5.7.19, for Linux (x86_64) using EditLine wrapper
Harden MySQL Server by running
Step 2 - Install NGINX
Next, we need to install NGINX software. It will be used as a reverse proxy for our Ghost application. Ghost-CLI can configure NGINX as a reverse proxy for you automatically.
Download and install NGINX:
sudo apt install -y nginx
Check NGINX version:
sudo nginx -v # nginx version: nginx/1.10.3 (Ubuntu)
Step 3 - Install Node.js and NPM
Ghost v1.0.0 currently supports Node.js versions 6.9+ and 4.5+ only. The recommended version of Node.js to use with Ghost v1.0.0 is currently Node.js v6 Boron LTS.
Ghost is built on Node.js. Ghost is following Node's LTS plan, only supporting LTS versions of Node.js. So, we will need to install latest LTS version of Node.js.
Download and install Node.js and NPM:
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash - sudo apt install -y nodejs
Check Node.js and NPM version:
node -v && npm -v # v6.11.3 # 3.10.10
Step 4 - Install Ghost-CLI
Ghost-CLI is a CLI tool for installing and updating Ghost. It makes installing and updating Ghost easy. It can set up database for you, configure NGINX as a reverse proxy, set up TLS security by using Let's Encrypt, automatic SSL renewal and set up ghost as a systemd service. It will take care of basic security for you, by creating dedicated system user called
ghost for running Ghost blog.
Install Ghost-CLI via npm:
sudo npm install -g ghost-cli@latest
Check Ghost-CLI version:
ghost version # Ghost-CLI version: 1.1.1
ghost doctorcommand to check that your environment is compatible with Ghost-CLI:
ghost doctor ✔ Checking system Node.js version ✔ Checking current folder permissions ✔ Checking operating system ✔ Checking MySQL is installed ✔ All install checks passed
Get help about
To get more specific help about
ghostsubcommands you can run
ghost help <command>. For example to get help about
ghost configcommand, run:
ghost help config
Step 5 - Install Ghost
NOTE: Make sure DNS records for your domain are set up. This tutorial uses example domain
blog.example.tldwith your domain/hostname.
Now we are ready to install Ghost CMS. The only way to install Ghost v1.0.0 is by using Ghost-CLI tool.
Create document root directory:
sudo mkdir -p /var/www/ghost
Change the ownership of the
/var/www/ghostdirectory to the non-root user with
sudoprivileges that you have created in the beginning of this tutorial:
sudo chown <johndoe>:<johndoe> /var/www/ghost
Navigate to document root directory:
NOTE: Make sure
/var/www/ghostdirectory is empty before installing Ghost and your user must own this directory.
Install Ghost in a production mode:
Answer the questions it prompts with. For more information about questions it prompts visit Ghost docs:
? Enter your blog URL: https://blog.example.tld ? Enter your MySQL hostname: localhost ? Enter your MySQL username: root ? Enter your MySQL password: [Enter password you created when you installed MySQL] ? Enter your Ghost database name: [Whatever you want] ? 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) [Your email for Let's Encrypt] ? Do you wish to set up "ghost" mysql user? yes ? Do you wish to set up Systemd? yes ? Do you want to start Ghost? yes
NOTE: After installation, NGINX configuration files will be in
/var/www/ghost/system/filesdirectory. Ghost-CLI will ask you
Do you wish to set up Nginx?and if your answer is
yes, then it will configure NGINX as a reverse proxy for you automatically. Your NGINX config files will be in
After installation is complete you can run
ghost lsto view running Ghost process:
Also to check if Ghost is installed you can run
ghost versionagain from
ghost version # Ghost-CLI version: 1.1.1 # Ghost Version (at /var/www/ghost): 1.8.4
In future when newer version of Ghost is released just run
ghost updatecommand in from
/var/www/ghostdirectory to update ghost. Also, before updating make a backup of you blog from admin interface.
To complete the setup process and create Ghost admin account, navigate to the Ghost configuration page by appending
/ghostto the end of your blog’s URL. This example uses
We have successfully installed and configured our new Ghost v1.0.0 blog for production. Ghost-CLI tool makes our life much easier by eliminating manual steps we had to do with older
v0.11.x Ghost. You can also do everything manually without the help of Ghost-CLI tool but you will lose the ability to easily update your blog with
ghost update command. Doing everything manually is laborious and not recommended. The only downside is the fact that other Linux distributions are not supported at this moment.