How to install Ghost on Ubuntu 18.04

s2 0

Ghost is a modern source publishing platform based on the Node.js platform. It’s fully customizable and easy to use, so you can publish your content without a learning curve.

In this tutorial we are going to show you how to run a secure ghost blog on an Ubuntu 18.04 server with Nginx as a proxy, the free Let’s Encrypt SSL certificate, the latest LTS version of Node.js and MySQL / MariaDB as the database backend provide .


The prerequisites for this tutorial are:

  • According to the official Ghost system requirements, you need at least 1 GB of RAM. If you have a server with less than 1 GB of RAM, you can create a paging file.
  • A domain name that points to your public server IP. In this tutorial we will use
  • Installed Nginx by following how to install Nginx on Ubuntu 18.04.
  • Firewall configured by how to set up a firewall with UFW on Ubuntu 18.04. Make sure ports 80 and 443 are open.

Before proceeding with this tutorial, make sure that you are logged in as a user with sudo permissions.

Install Node.js and Yarn

At the time of this writing, the recommended version of Node.js for Ghost v8 is Carbon LTS. We install Node.js from the NodeSource repository.

Enable the NodeSource repository for Node.js v8 as follows curl Command:

curl -sL | sudo bash -

Install Node.js by typing:

sudo apt install nodejs
For more installation methods, see our guide on installing Node.js on Ubuntu 18.04.

To install yarn, first enable the yarn repository on your system with the following commands:

curl -sS | sudo apt-key add -echo "deb stable main" | sudo tee /etc/apt/sources.list.d/yarn.list

Once the repository is activated, install yarn using:

sudo apt updatesudo apt-get -o Dpkg::Options::="--force-overwrite" install yarn

Install MySQL

Ghost supports MySQL, MariaDB, and SQLite databases. In this tutorial we are going to use MySQL, the recommended database when running Ghost in production mode.

Install the MySQL package with the following command:

sudo apt install mysql-server

Run the mysql_secure_installation Command to improve the security of the MySQL installation:

sudo mysql_secure_installation

You will be prompted for the VALIDATE PASSWORD PLUGIN which is used to test the strength of MySQL user passwords. There are three levels of password validation policy: low, medium, and strong. Press ENTER if you don’t want to set up the Validation Password Plugin.

At the next prompt, you will be asked to set a password for the MySQL root user.

Once you’ve set the root password, the script will also prompt you to remove the anonymous user, restrict root user access to the local computer, and remove the test database. You should answer Y (yes) to all questions.

Next we need to change the authentication method from auth_socket to mysql_native_passwordso that the Ghost installer can access our MySQL server. To do this, log on to the MySQL server as the root user:

sudo mysql

and run the following query which sets a password for the MySQL root user if you are using that mysql_native_password Method:

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'very_strong_pasword';FLUSH PRIVILEGES;

Make sure you change yourself very_strong_pasword with a strong password.

Install the Ghost CLI

We install Ghost using the official Ghost CLI utility. This utility allows you to install or update Ghost with a single command.

Ghost CLI is available as an npm package. The following command installs Ghost CLI globally on your Ubuntu system:

sudo yarn global add ghost-cli

Create a Ghost installation location

We’ll download and install Ghost in the /var/www/ghost Directory that is the recommended installation location.

To create the directory type:

sudo mkdir -p /var/www/ghost

Change the owner of the directory to your user:

sudo chown $USER:$USER /var/www/ghost

$USER is an environment variable that contains your username.

Set the correct directory permissions:

sudo chmod 775 /var/www/ghost

Install Ghost

After you’ve installed the Ghost CLI and all of the prerequisites have been met, we can start the installation.

Switch to the /var/www/ghost Directory.

cd /var/www/ghost

To start the installation run ghost installwho installs and configures Ghost, configures Nginx as a reverse proxy, and secures the site with a free SSL certificate from Let’s Encrypt.

ghost install
✔ Checking system Node.js version
✔ Checking logged in user
✔ Checking current folder permissions
System checks failed with message: 'Linux version is not Ubuntu 16'
Some features of Ghost-CLI may not work without additional configuration.
For local installs we recommend using `ghost install local` instead.
? Continue anyway? (y/N) y

The installer will check your system and print out some warnings as shown above. Type y to proceed and the installer will download and install Ghost:

ℹ Checking operating system compatibility [skipped]
✔ Checking for a MySQL installation
✔ Checking memory availability
✔ Checking for latest Ghost version
✔ Setting up install directory
✔ Downloading and installing Ghost v1.24.9
✔ Finishing install process

Next, you will be asked to set your blog url and MySQL information. Provide the root username and password we set up in the Installing MySQL Section and use the default database name ghost_prod.

? Enter your blog URL:
? Enter your MySQL hostname: localhost
? Enter your MySQL username: root
? Enter your MySQL password: [hidden]
? Enter your Ghost database name: ghost_prod

The installer creates a system user named ghost and will ask if you want to create a ghost MySQL user type Yes.

✔ Configuring Ghost
✔ Setting up instance
Running sudo command: chown -R ghost:ghost /var/www/ghost/content
✔ Setting up "ghost" system user
? Do you wish to set up "ghost" mysql user? Yes
✔ Setting up "ghost" mysql user

Next, the installer will ask if you want to set up Nginx. Confirm by entering Yes.

? Do you wish to set up Nginx? Yes
✔ Creating nginx config file at /var/www/ghost/system/files/
Running sudo command: ln -sf /var/www/ghost/system/files/ /etc/nginx/sites-available/
Running sudo command: ln -sf /etc/nginx/sites-available/ /etc/nginx/sites-enabled/
Running sudo command: nginx -s reload
✔ Setting up Nginx

Once Nginx is set up, the installer will ask if you want to set up SSL. Confirm by entering Yes and the configuration wizard asks you to enter your email address and then generates a free Let’s Encrypt SSL certificate for your domain and configures Nginx.

? Do you wish to set up SSL? Yes
? Enter your email (used for Let's Encrypt notifications) [email protected]
Running sudo command: mkdir -p /etc/letsencrypt
Running sudo command: ./ --install --home /etc/letsencrypt
Running sudo command: /etc/letsencrypt/ --issue --home /etc/letsencrypt --domain --webroot /var/www/ghost/system/nginx-root --reloadcmd "nginx -s reload" --accountemail [email protected]
Running sudo command: openssl dhparam -out /etc/nginx/snippets/dhparam.pem 2048
Running sudo command: mv /tmp/ssl-params.conf /etc/nginx/snippets/ssl-params.conf
✔ Creating ssl config file at /var/www/ghost/system/files/
Running sudo command: ln -sf /var/www/ghost/system/files/ /etc/nginx/sites-available/
Running sudo command: ln -sf /etc/nginx/sites-available/ /etc/nginx/sites-enabled/
Running sudo command: nginx -s reload
✔ Setting up SSL

Next, the installer will ask if you want to set up a systemd service. Type Y accept and the installer will create a new systemd service called ghost_example-com and allow it to start at boot:

? Do you wish to set up Systemd? Yes
✔ Creating systemd service file at /var/www/ghost/system/files/ghost_example-com.service
Running sudo command: ln -sf /var/www/ghost/system/files/ghost_example-com.service /lib/systemd/system/ghost_example-com.service
Running sudo command: systemctl daemon-reload
✔ Setting up Systemd

Finally, the installer sets up the database and asks if you want to start Ghost, type Yes.

Running sudo command: /var/www/ghost/current/node_modules/.bin/knex-migrator-migrate --init --mgpath /var/www/ghost/current
✔ Running database migrations
? Do you want to start Ghost? Yes
Running sudo command: systemctl is-active ghost_example-com
✔ Ensuring user is not logged in as ghost user
✔ Checking if logged in user is directory owner
✔ Checking current folder permissions
Running sudo command: systemctl is-active ghost_example-com
✔ Validating config
✔ Checking folder permissions
✔ Checking file permissions
✔ Checking content folder ownership
✔ Checking memory availability
Running sudo command: systemctl start ghost_example-com
✔ Starting Ghost
Running sudo command: systemctl is-enabled ghost_example-com
Running sudo command: systemctl enable ghost_example-com --quiet
✔ Starting Ghost
You can access your publication at
Next, go to your admin interface at to complete the setup of your publication

Ghost uses direct mail by default
To set up an alternative email method read our docs at

Complete the ghost setup

Open your browser, go to your Ghost administration interface below and you will see the following screen:

To get started, click that Create your account Button.

You will be taken to the Create Account screen where you will need to enter your blog title, full name, email address and password:

Once you have filled in the details and click on Invite your team Button.

On this screen, you will be asked to enter your employees’ email addresses. You can just click on the I'll do this later, take me to my blog! Link and you will be taken to the Ghost dashboard:

From here you can create new posts, add users, and change the Ghosts configuration.


In this tutorial, you learned how to install a production-ready Ghost instance.

You should visit them now Ghost help
Page and learn more about how to manage your Ghost installation. Also visit the Ghost market
and discover the ghost themes.