Friendly Ghost

Command Line

© Lead Image, toa-heftiba,

© Lead Image, toa-heftiba,

Article from Issue 210/2018

Blogging usually implies WordPress, but Ghost presents a serious challenge.

According to an analysis by W3Techs [1], neither Google nor Amazon control the Internet – the WordPress content management system (CMS) does. They say the open source CMS now drives 30 percent of all websites, which translates to a market share of just over 60 percent. Thus, you are unlikely to go a day without stumbling across a WordPress page while browsing.

Even though most web developers are looking for one of the usual candidates from the CMS trio of WordPress, Joomla, and Drupal, you should take a look at the CMS inhabiting the bottom of the W3Techs list. The still quite new Ghost [2] has only secured a small share of the market, but its modern approach and its active community make the CMS interesting for open source-minded bloggers.


In contrast to WordPress, the Ghost CMS does not rely on PHP, but on JavaScript and Node.js, which makes it a bit difficult to get started. However, the modern web platform plays to its strengths. The idea for Ghost came from Hannah Wolfe and John O'Nolan, who gained great experience in CMS as the former deputy head of design of the WordPress team. O'Nolan no longer sees WordPress as the simple tool for bloggers that it once was, but as a platform for all kinds of web projects [3]. With a handful of plugins, you can set up virtually any project on the web, from a bug tracker to a web shop to an online community.

Its great flexibility is also the biggest weakness of WordPress: The CMS has lost its focus on the original target group, bloggers, which are exactly who Ghost is now targeting. The project was given a significant boost by a successful Kickstarter campaign. In just under a month, around £200,000 came together, which was far more than the £25,000 funding target [4].

The Ghost Foundation emerged from the accumulated capital and developed and managed the code under the MIT license as a non-profit organization. The foundation currently employs eight people, and the steadily growing community contributes time and code to the project. As with WordPress, the Ghost CMS is available for self-hosting, or Ghost(Pro) [5] is offered as a hosted version for a fee starting at $19 a month.


Ghost recommends Ubuntu 16.04 with 1GB of RAM, MySQL as the database back end, and Nginx as the web server. As a JavaScript application based on Node. js [6], Ghost provides its own web server. Node.js listens for requests on port 1024 or greater so that the service does not have to run with root privileges, and Nginx accepts requests on ports 80 and 443 (for SSL) as a reverse proxy before passing them on to Ghost. In a test on Ubuntu Server 17.10, Ghost proved in our lab that it can handle a state-of-the-art software stack.

As a prerequisite, we assume that the server can be reached over an Internet domain. In the case of a home server connected to the Internet via DSL or cable, you must ensure that the URL is accessible via DynDNS and forward ports 80 and 443 from the router to the server. Refer to the Installation Guide [7] to update the server and install Nginx and MySQL. The system requests a root password for the SQL server (which you must remember); then, you need to activate the web server in the firewall (Listing 1).

Listing 1

Activating Web Server

$ sudo apt update
$ sudo apt full-upgrade
$ sudo apt install nginx mysql-server
$ sudo ufw allow 'Nginx Full'


Ghost developers recommend using the 6.x LTS branch of Node.js. Ubuntu 16.04 and newer is the easiest way to load it via The installation script inserts a package source into the system, from which it then installs the application. With the node package manager (npm), you can install the ghost-cli setup wizard:

$ wget
$ chmod +x setup_6.x
$ sudo ./setup_6.x
$ sudo apt install nodejs
$ sudo npm i -g ghost-cli

At first glance, this procedure might seem complicated, but it saves much time and effort in the long run.

At this point, you have created the necessary prerequisites to put the blog system on the server:

$ sudo mkdir -p /var/www/ghost
$ sudo chown <User>:<Group> /var/www/ghost
$ cd /var/www/ghost
$ LANG=C ghost install

The first line creates the /var/www/ghost/ working directory; the second line assigns the user rights to the folder. Next, you switch to the newly created directory, which must be empty, and run the installation wizard. The LANG=C changes the language settings to the default locale; otherwise, the script runs into an error and terminates.

The installation routine first wants to know the blog URL, the address of the MySQL server, the root login, and the previously assigned MySQL password, as well as a name for the database. You can enter the URL to access the blog later. If the blog and database are on the same computer, the address for the MySQL server is localhost. The database does not have to exist: The setup creates it, if necessary.

The Ghost command-line interface (CLI) handles most of the maintenance work and the installation. You can install the current version with ghost update. Alternatively, take a look at what's going on behind the scenes with ghost log. For information on all options of the Ghost client for the command line, enter ghost help.

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

comments powered by Disqus