This post shows students and new users the steps to install Ghost CMS on Ubuntu Linux with Nginx support. Ghost is a powerful open source publishing platform for the modern web built on top of the Node.js platform.

Ghost 2.0 introduces many new features, including a powerful new editor, multi-language support, custom home pages, dynamic paths, custom structures, and much more.

Ghost is a clean and lightweight platform designed for bloggers who want to focus on blogging and nothing else. Unlike WordPress and other PHP-based content management systems, Ghost is simple in design and function. No additional packages or servers needed, just JavaScript.

In this post, we will show you how to install Nginx as proxy, MariaDB, and use Let’s Encrypt SSL certificate to protect website from Ghost.

To learn more about Ghost, visit his Homepage.

To start installing Ghost on Ubuntu Linux, follow the steps below:

How to install Nginx on Ubuntu Linux

In this post, we are going to install the Nginx HTTP server to serve as a proxy for Ghost. Nginx is lightweight and should be perfect to run with Ghost.

To install Nginx, run the following commands:

sudo apt update
sudo apt install nginx

After installing Nginx, the following commands can be used to stop, start, and enable the Nginx service to always start with the server starting.

sudo systemctl stop nginx.service
sudo systemctl start nginx.service
sudo systemctl enable nginx.service

Once Nginx is installed, open a web browser and look for the server’s hostname or IP address. If you see a welcome page for Nginx, Nginx has been installed and is running correctly on Ubuntu.

test the default nginx home page

How to install MariaDB on Ubuntu Linux

Ghost also requires a database server to store its content. If you are looking for a truly open source database server, MariaDB is a great place to start.

To install MariaDB, run the following commands:

sudo apt install mariadb-server

After installing MariaDB, the following commands can be used to stop, start, and enable the MariaDB service to always start when the server starts.

sudo systemctl stop mariadb.service
sudo systemctl start mariadb.service
sudo systemctl enable mariadb.service

After that, run the commands below to secure the MariaDB server by creating a root password, not allowing remote root access, removing anonymity, and more.

sudo mysql_secure_installation

When prompted, answer the following questions by following the guide.

If you've just installed MariaDB, and haven't set the root password yet, you should just press enter here.

Enter current password for root (enter for none): PRESS ENTER

Switch to unix_socket authentication [Y/n] n

Change the root password? [Y/n] n

Remove anonymous users? [Y/n] y

Disallow root login remotely? [Y/n] y

Remove test database and access to it? [Y/n] y

Reload privilege tables now? [Y/n] y

All done!

The latest MariaDB servers come with the root user configured to use the auth_socket default authentication method.

the auth_socket The plugin authenticates users connecting from localhost through the Unix socket file. This means that you cannot authenticate as root by providing a password.

This can cause problems with some applications that need to connect to the database via root. To fix this, you will need to change the default authentication mechanism from auth_socket for mysql_native_password.

However, doing so could present security risks, as root users should not be used to remotely connect to the database. A recommended method is to create a dedicated user to remotely connect to your database servers.

Since you don’t want to connect to the MariaDB database server from phpMyAdmin as root user, you should probably create a separate account instead of connecting with root.

Run the following commands to log into the MariaDB server.

sudo mysql -u root -p

Then run the SQL commands below to create a new user for Ghost to use to connect to the database.

CREATE USER 'ghostadmin'@'localhost' IDENTIFIED BY 'very_strong_password_here';

Then give the user full access to manage the database server.

GRANT ALL PRIVILEGES ON *.* TO 'ghostadmin'@'localhost' WITH GRANT OPTION;

If you see a screen similar to the one shown above, then the server installed successfully.

Create a ghost database on Ubuntu Linux

Now that you have installed all the necessary packages for Ghost to work, continue below to begin configuring the servers. First run the following commands to create a blank Ghost database.

To log in to the MariaDB database server, run the following commands.

sudo mysql -u root -p

Then create a database called ghost


Then use the Ghost account created earlier and give it access to the ghost database.

GRANT ALL ON ghost.* TO 'ghostadmin'@'localhost' WITH GRANT OPTION;

Finally, save your changes and exit.


How to install Node.js on Ubuntu Linux

Since Ghost is based on Node.js, run the following commands to download the Node.js version 14 LTS packages from your repository.

sudo apt install curl
curl -sL | sudo bash -

Then run the following commands to install Node.js and the necessary packages for Ghost to work. The Nginx web server will be needed for this. s

sudo apt install nodejs

Then run the following commands to include the Yarn repository and enable it.

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

Once the repository is enabled, install yarn with:

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

How to download and install Ghost

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

Run the following commands to install the Ghost installation tool.

sudo yarn global add ghost-cli

We are going to create a folder for the Ghost content in the / var / www / ghost directory. To create the folder, run the following commands.

sudo mkdir -p /var/www/ghost

Next, change the ownership of the folder to your account so that you can run the Ghost tool to download Ghost packages.

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

Then change to the directory and install Ghost.

cd /var/www/ghost

To start the installation, run the following command. The command will install and configure Ghost, configure Nginx as a reverse proxy, and protect the site with a free encryption SSL certificate.

ghost install

You should start to see Ghost change for the packages that are required. Once everything is validated, Ghost should start downloading its package dependencies to install.

 Checking system Node.js version - found v14.18.0
✔ Checking logged in user
✔ Checking current folder permissions
✔ Checking system compatibility
✔ Checking for a MySQL installation
✔ Checking memory availability
✔ Checking free space
✔ Checking for latest Ghost version
✔ Setting up install directory
Downloading and installing Ghost v4.16.0 > Installing dependencies >

Next, configure the database connection with the information created earlier.

? Enter your blog URL:
? Enter your MySQL hostname: localhost
? Enter your MySQL username: ghostadmin
? Enter your MySQL password: [hidden]
? Enter your Ghost database name: ghost
✔ Configuring Ghost
✔ Setting up instance

When asked if you want to configure Nginx, type yes.

 Setting up "ghost" system user
ℹ Setting up "ghost" mysql user [skipped]
? Do you wish to set up Nginx? Yes
+ sudo nginx -s reload
✔ Setting up Nginx
? Do you wish to set up SSL? Yes
? Enter your email (For SSL Certificate)
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
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

When prompted with the questions below, choose yes.

 Do you wish to set up Systemd? Yes
✔ Setting up Systemd
? Do you want to start Ghost? Yes
✔ Starting Ghost

If all went well, you should see a configuration complete message similar to the one below.

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

After that, open your browser and navigate to the Ghost administration interface using the server’s hostname or IP address followed by /ghost/
Ghost Ubuntu Configuration

To get started, click on the creat your account to create your account and start configuring Ghost.

You should do that!


In this tutorial we have seen how to install Ghost CMS on Ubuntu with Nginx. If you find any errors above or have something to add, please use the comment form below.

Write A Comment