How to Install Ghost Blogging Platform on Ubuntu 16.04 Server

This tutorial will be showing you how to install the Ghost blogging platform on Ubuntu 16.04 server. Ghost is an open-source blogging software coded in Node.js, allowing you to create modern, beautiful blogs. Compared to WordPress, Ghost is lightweight and much faster because it’s built specifically for blogging and isn’t a comprehensive content management system like WordPress.

Ghost features:

  • A Markdown-based editor allowing your to quickly write posts.
  • Simple content management.
  • Collaborative editing with your team.
  • Scheduled publishing
  • Built-in analytics
  • Proper SEO built in directly, with semantic markup, permalinks, XML sitemaps, canonical tags and automatic meta data with manual overrides.
  • Integrated AMP (Accelerated Mobile Pages) support
  • Full RSS feeds, email subscription capture forms and Slack webhook integration
  • Hundreds of beautiful free and premium themes are available from the Ghost marketplace
  • A cross-platform desktop app available for Linux, Mac and Windows.

The Ghost foundation offers managed hosting, but here we will see how to create a self-hosted Ghost blog on Ubuntu 16.04.

How to Install Ghost on Ubuntu 16.04 Server

Step 1: Update Ubuntu 16.04

If you server hasn’t been updated for some time, then run the following command to update.

sudo apt update && sudo apt upgrade

Step 2: Install Node.js on Ubuntu

Ghost requires you to install the LTS version of Node.js and does not support non-LTS version. You can install the latest LTS version, which is Node.js 6.10.x.

Add NodeSource repository using the command below.

curl -sL | sudo -E bash -

Then install Node.js.

sudo apt install nodejs

Check Node version.

node -v

Sample output:


Check npm version:

npm -v

Sample output:


Step 3: Install Ghost

Download the latest version of Ghost using curl.

curl -L -o

If your Ubuntu doesn’t have curl, you can use wget instead.

wget -O

Then create a directory (/var/www/ghost/) for Ghost.

sudo mkdir -p /var/www/ghost/

Install unzip utility and unzip the file into that directory.

sudo apt install unzip

sudo unzip -d /var/www/ghost/

Now change working directory to /var/www/ghost/ and install Ghost.

cd /var/www/ghost/

sudo npm install --production

The installation may take a while.

Step 4: Configure Ghost

By default Ghost listens on and the default URL for your Ghost blog is This is fine for a local install, but if your Ghost blog is installed on a remote system, then you need to change these configurations in order to visit your blog.

Ghost uses a config file named config.js. We need to copy the /var/www/ghost/config.example.js file and name it config.js.

sudo cp config.example.js config.js

Then open this file.

sudo nano config.js

Find the following line.

url: '',

Change the URL to your domain name or your server’s IP address.

url: 'http://your_domain_or_ip_address',

Then find the following lines.

 server: {
    host: '',
    port: '2368'

Change to, which makes your Ghost blog available for the whole Internet. Save and close the file.

Step 5: Run Ghost

Start your Ghost blog.

sudo npm start --production

install ghost blog ubuntu 16.04

Now enter your domain name (Don’t forget to set A record.) or your server’s IP address in the browser address bar. You will see the home page of your Ghost blog.


install ghost blog ubuntu

Step 6: Set up Nginx Reverse Proxy

You can use Nginx as the front end server for Ghost.  Since Ghost runs in the foreground, you can establish a separate SSH session to your Ubuntu 16.04 server in order to keep it running and at the same time be able to enter commands.

Install Nginx on Ubuntu 16.04.

sudo apt install nginx

Then create an Nginx server block file for Ghost.

sudo nano /etc/nginx/conf.d/ghost.conf

Put the following text into the file. Replace with your own domain.

server {
        listen 80;

        location / {
                proxy_set_header  X-Real-IP  $remote_addr;
                proxy_set_header  Host       $http_host;

The proxy_pass directive will proxy all requests to Save and close the file. Then test Nginx configuration.

sudo nginx -t

If the test if successful, reload Nginx.

sudo systemctl reload nginx

Now you can visit your Ghost blog using a domain name and without having to specify port number. The Ghost admin panel is available at

Step 7: Make Ghost Run at Startup

We can create a Systemd service for Ghost and then enable this service. Create a systemd service file.

sudo nano /etc/systemd/system/ghost.service

Put the following lines into the file.

Description=Ghost Blog



ExecStart=/usr/bin/npm start --production
ExecStop=/usr/bin/npm stop --production
SyslogIdentifier=Ghost Blog


Note that we’ve specified Ghost should run as www-data user.  This way, hackers won’t gain root access should your Ghost blog get hacked.

Save and close the file. Then make www-data user the owner of the /var/www/ghost directory:

sudo chown -R www-data:www-data /var/www/ghost/

Next, enable this service, which means Ghost will run at startup.

sudo systemctl enable ghost.service

Now we can move to the previous SSH session and press CTRL+C to stop the current Ghost. Next, run the following command to start Ghost as a service.

sudo systemctl start ghost.service

Step 8: Enable HTTPS with Let’s Encrypt

To install the latest version of certbot (Let’s Encrypt client), we can use official PPA.

sudo add-apt-repository ppa:certbot/certbot
sudo apt update
sudo apt install certbot

If we use the webroot plugin to obtain SSL certificate, we need to allow access to the /var/www/ghost/.well-known/acme-challenge/ directory. Edit the Nginx server block file for Ghost.

sudo nano /etc/nginx/conf.d/ghost.conf

Add the following lines in the server block.

location ~ /.well-known/acme-challenge {
                root /var/www/ghost/;
                allow all;

ghost nginx

Save and close the file. Reload Nginx.

sudo systemctl reload nginx

Next run the following command to obtain an SSL certificate using the webroot plugin. Replace red text with your own data.

sudo certbot certonly --agree-tos --webroot --email your-email-address -d -w /var/www/ghost/

Once the command is finished, you should successfully get a SSL certificate from Let’s Encrypt.

ghost blog ssl

Now edit the Ghost server block file to install the certificate.

sudo nano /etc/nginx/conf.d/ghost.conf

Change the configuration as follows:

server {
      listen 80;
      return 301 https://$server_name$request_uri;
server {
      listen 443 ssl http2;

      ssl_certificate /etc/letsencrypt/live/;
      ssl_certificate_key /etc/letsencrypt/live/;

      ssl_session_timeout 1d;
      ssl_session_cache shared:SSL:50m;
      ssl_session_tickets off;

    # modern configuration. tweak to your needs.
    ssl_protocols TLSv1.2;
    ssl_prefer_server_ciphers on;

    # HSTS (ngx_http_headers_module is required) (15768000 seconds = 6 months)
    add_header Strict-Transport-Security max-age=15768000;

    # OCSP Stapling ---
    # fetch OCSP records from URL in ssl_certificate and cache them
    ssl_stapling on;
    ssl_stapling_verify on;

     location / {
            proxy_set_header  X-Real-IP  $remote_addr;
            proxy_set_header  Host       $http_host;

     location ~ /.well-known/acme-challenge {
            root /var/www/ghost/;
            allow all;

Save and close the file. Then test Nginx configuration and reload.

sudo nginx -t

sudo systemctl reload nginx

Visit in web browser to verify Ghost blog is running correctly in HTTPS mode.

That’s it! I hope this tutorial helped you install Ghost on Ubuntu, set up Nginx reverse proxy and install SSL certificate.

Rate this tutorial
[Total: 8 Average: 4.8]

Leave a Comment

  • Comments with links are moderated by admin before published.
  • Your email address will not be published.
  • Use <pre> ... </pre> HTML tag to quote the output from your terminal/console.
  • Please use the community ( for questions unrelated to this article.
  • If my answer helped you, please consider supporting this site. Thanks :)