How to Install Ghost Blogging Platform on Ubuntu Server 18.04/20.04

This tutorial will be showing you how to install the Ghost blogging platform on Ubuntu 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

At the time of writing, the latest version of Ghost is v3.2.0, release in December 23, 2019. Features of Ghost are as follows:

  • A Markdown-based editor allowing you 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 nice-looking default theme Capser with dark mode support.
  • A cross-platform desktop app available for Linux, Mac, and Windows.
  • The official Ghost Migrator WordPress plugin allows you to easily migrate from WordPress to Ghost.

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

install ghost blog on ubuntu server

Prerequisites of Installing Ghost on Ubuntu Server

To run a Ghost blog, you need a server with at least 1GB RAM. You can click this special link to get $50 free credit on DigitalOcean. (For new users only). If you are already a DigitalOcean user, then you can click this special link to get $50 free credit on Vultr (for new users only). Once you have an account at DigitalOcean or Vultr, install Ubuntu on your server and follow the instructions below. For best compatibility, please use the LTS version of Ubuntu like Ubuntu 18.04 or 16.04.

You also need to have a domain name. I registered my domain name from NameCheap because the price is low and they give whois privacy protection free for life.

Note: I installed Ghost with a sudo user on Ubuntu. For best results, you should also follow this tutorial with a sudo user, not root. To add a sudo user, simply run

sudo adduser username
sudo adduser username sudo

Then switch to the new user.

su - username

Step 1: Update Ubuntu

If your server hasn’t been updated for some time, then run the following command to update existing software packages.

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. The latest LTS version of Node.js is v12.x, but currently Ghost is more compatible with Node.js v10.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 MariaDB Database Server

supports MySQL and MariaDB. MariaDB is a drop-in replacement for MySQL. It is developed by former members of MySQL team who are concerned that Oracle might turn MySQL into a closed-source product. So let’s install the MariaDB database server.

Enter the following command to install it on Ubuntu 18.04/20.04.

sudo apt install mariadb-server mariadb-client

After it’s installed, MariaDB server should be automatically stared. Use systemctl to check its status.

systemctl status mariadb

Sample output:

 mariadb.service - MariaDB 10.1.34 database server
   Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
   Active: active (running) since Sat 2018-09-08 11:13:27 UTC; 21s ago
     Docs: man:mysqld(8)
 Main PID: 3473 (mysqld)
   Status: "Taking your SQL requests now..."
    Tasks: 27 (limit: 505)
   CGroup: /system.slice/mariadb.service
           └─3473 /usr/sbin/mysqld

If it’s not running, start it with this command:

sudo systemctl start mariadb

To enable MariaDB to automatically start at system boot time, run

sudo systemctl enable mariadb

Now run the post installation security script.

sudo mysql_secure_installation

When it asks you to enter MariaDB root password, press Enter key as the root password isn’t set yet. Then enter y to set the root password for MariaDB server.

Ubuntu 18.04 lamp mariadb

Next, you can press Enter to answer all remaining questions, which will remove anonymous user, disable remote root login and remove test database. This step is a basic requirement for MariaDB database security. (Note that the letter Y is capitalized, which means it’s the default answer.)

ubuntu 18.04 lamp stack mariadb serverCheck MariaDB server version information.

mariadb --version


mariadb Ver 15.1 Distrib 10.1.34-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2

Step 4: Create a Database and User for Ghost

Now we need to log in to MariaDB console and create a database and user for Ghost . By default, the MaraiDB package on Ubuntu uses unix_socket to authenticate user login, which basically means you can use username and password of the OS to log into MariaDB console. So you can run the following command to login without providing MariaDB root password.

sudo mariadb -u root

Create a database for Ghost using the following command. I named it ghost, but you can use whatever name you like. (Don’t leave out the semicolon.)

create database ghost;

Then enter the command below to create a database user for Ghost and grant all privileges of the ghost database to the user.

grant all privileges on ghost.* to ghost@localhost identified by 'ghost_password';

Flush the privileges table for the changes to take effect and then get out of MariaDB console.

flush privileges;


Step 5: Install Nginx Web Server

Ghost will use Nginx web server, so run the following command to install it from the default Ubuntu repository.

sudo apt install nginx

If you are using the UFW firewall, then you also need to open port 80 and 443.

sudo ufw allow 80/tcp
sudo ufw allow 443/tcp

Step 6: Create A Record For Your Blog Domain Name

Before installing Ghost, it’s recommended that you create the DNS A record for your blog domain name. The A record points your domain name to the IP address of your Ubuntu server.

Step 7: Install Ghost

Install Ghost-CLI.

sudo npm install [email protected] -g

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

sudo mkdir -p /var/www/ghost/

Grant permissions to your user account. Replace username with your real username.

sudo apt install acl

sudo setfacl -R -m u:username:rwx /var/www/ghost/

sudo chmod 775 /var/www/ghost

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

cd /var/www/ghost/

ghost install

The installation may take a while. During the installation you will be asked to enter your blog URL. Enter something like And you will need to enter the MariaDB database name, user credentials you created in step 4.

? Enter your blog URL:
? Enter your MySQL hostname: localhost
? Enter your MySQL username: ghost
? Enter your MySQL password: ghost_password
? Enter your Ghost database name: ghost

If you are using Ubuntu 20.04 and see the following message, you can ignore it and continue the installation.

System checks failed with message: 'Linux version is not Ubuntu 16 or 18'
Some features of Ghost-CLI may not work without additional configuration.
For local installs we recommend using `ghost install local` instead.

A ghost system user will be automatically created. It’s recommended that you accept to set up Nginx and SSL, so your blog will be available via the secure HTTPS protocol. Also, accept to set up the Systemd service so you will be able to start, stop or restart Ghost easily.

Once Ghost was installed successfully, go to to complete the setup. First, you need to create an account.

create admin account in Ghost

Then you can invite some staff users to your Ghost blog, or you can do it later.

Step 8: Edit the Nginx Config File

By default, the Nginx configuration file for Ghost contains one domain name. If you want Nginx to serve both the www domain and the non-www domain, edit the configuration file.

sudo nano /etc/nginx/sites-enabled/

Find the following line


Add the www domain.


Save and close the file. Then delete the /etc/nginx/sites-enabled/ file.

sudo rm /etc/nginx/sites-enabled/

Then install the Certbot Let’s Encrypt client

sudo apt install certbot python3-certbot-nginx

Obtain SSL certificate for both the www domain and the non-www domain.

sudo certbot --nginx --agree-tos --redirect --hsts --staple-ocsp --email [email protected] -d,

Restart Nginx and you are done.

sudo systemctl restart nginx

Step 9: Set Up Email Notification

In order to send emails from your Ghost blog (for password resetting, invite staff users, member signup, etc), you need to configure the SMTP settings. If you would like to use your own email server, please read the following tutorial to easily set up your own email server.

Once you have your own email server, edit the Ghost configuration file.

sudo nano /var/www/ghost/config.production.json

By default the mail settings are as follows:

"mail": {
   "transport": "Direct"

Change it to use SMTP.

"mail": {
    "transport": "SMTP",
    "from": "[email protected]",
    "options": {
        "service": "",
        "host": "",
        "port": 465,
        "secureConnection": true,
        "auth": {
            "user": "[email protected]",
            "pass": "the_email_account_password"

Note that Ghost doesn’t support port 587 for SMTP. Save and close the file. Then restart Ghost via the systemd service.

sudo systemctl restart ghost_yourdomain-com.service

Now your Ghost blog should be able to send emails.

Wrapping Up

That’s it! I hope this tutorial helped you install Ghost on Ubuntu server. As always, if you found this post useful, then subscribe to our free newsletter to get more tips and tricks. Take care 🙂

Rate this tutorial
[Total: 8 Average: 4.8]

9 Responses to “How to Install Ghost Blogging Platform on Ubuntu Server 18.04/20.04

  • Vinodh Moodley
    1 year ago

    Digital Ocean have a one-click image that does most of this work for you. Your tutorial is fantastic but I’m not at all familiar with most of what you talk about which makes the Digital Ocean image perfect for me.

    You can have your Ghost blog ready to be configured literally in a few seconds Using that image. My only issue so far with it is getting email configured.

  • Julian Tagell
    1 year ago

    I got the following at the end of the ghost install
    Message: ER_ACCESS_DENIED_ERROR: Access denied for user ‘ghost’@’localhost’ (using password: YES)
    I used the same password i set earlier on.

  • Julian Tagell
    1 year ago

    worked second time round. At the “sudo mysql_secure_installation” I entered my ssh keyphrase at the first “enter current password for root” instead of pressing enter… this seemed to work. ps, I don’t really know why… doing it your may might work, as well… just didn’t seem to work for me last time (might have entered it in incorrectly, or something, I might try again to double check). Cheers for the guide. Also, would you know anything about adding in an R shiny server to the droplet (and having it set to the sub-domain or ?) At the moment when I try this i get the ghost 404 page missing error.

  • sudo setfacl -R -m u:username:rwx /var/www/ghost/

    —> sudo: setfacl: command not found

  • Curtis Steinmetz
    9 months ago

    When I get to the “ghost install” step in Step 7 I get the following error message:

    System checks failed with message: ‘Missing package(s): nginx’

    I have nginx installed, as can be seen from output of which nginx:
    /var/www/ghost$ which nginx

    Any suggestions would be greatly appreciated!!!

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.
  • I don't have time to answer every question. Making a donation would incentivize me to spend more time answering questions.

The maximum upload file size: 2 MB. You can upload: image. Links to YouTube, Facebook, Twitter and other services inserted in the comment text will be automatically embedded. Drop file here