Ghost CMS

How to Install Ghost on Ubuntu 22.04

Ghost is an open-source powerful NodeJS-based Content Management System (CMS) for creating blog oriented websites. It has full support for Markdown and provides an easy-to-use web interface for administration purposes.

In this tutorial we will show you how to install Ghost CMS on a Ubuntu 22.04 OS.

Step 1: Add a new user

To install Ghost, we need to add normal user with root privileges.

# adduser linuxtuto

Note: Do not use username as a ghost it gets cause conflicts with the Ghost-CLI.

To add the user to the sudo group, use the usermod command as follows:

# usermod -aG sudo linuxtuto

Then log in as the new user:

# su - linuxtuto

Step 2: Update Operating System

Update your Ubuntu 22.04 operating system to make sure all existing packages are up to date:

$ sudo apt update && sudo apt upgrade -y

Step 3: Install Nginx webserver

You can install it via apt package manager by executing the following command:

$ sudo apt install nginx

Verify the status of the Nginx service using systemctl status command:

$ sudo systemctl status nginx


● nginx.service - A high performance web server and a reverse proxy server
     Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
     Active: active (running)
       Docs: man:nginx(8)
    Process: 66019 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
    Process: 66020 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
   Main PID: 66112 (nginx)
      Tasks: 2 (limit: 2196)
     Memory: 2.6M
        CPU: 148ms
     CGroup: /system.slice/nginx.service
             ├─66112 "nginx: master process /usr/sbin/nginx -g daemon on; master_process on;"
             └─66113 "nginx: worker process"

Step 4: Install MySQL

You can install the MySQL server with the following command:

$ sudo apt install mysql-server

Start the database server daemon, and also enable it to start automatically at the next boot with the following commands:

$ sudo systemctl start mysql
$ sudo systemctl enable mysql

Verify the status of the MySQL service using systemctl status command:

$ sudo systemctl status mysql


● mysql.service - MySQL Community Server
     Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
     Active: active (running)
   Main PID: 1083 (mysqld)
     Status: "Server is operational"
      Tasks: 41 (limit: 2797)
     Memory: 434.0M
        CPU: 1min 57.932s
     CGroup: /system.slice/mysql.service
             └─1083 /usr/sbin/mysqld

By default, MySQL is not hardened. You can secure MySQL using the mysql_secure_installation script.

$ sudo mysql_secure_installation

Configure it like this:

- Set root password? [Y/n] Y
- 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

Run the command below to log in to the MySQL shell.

$ sudo mysql -u root -p

Once you are logged in to your database server you need to create a database:

mysql> CREATE DATABASE ghostdb;
mysql> CREATE USER 'ghostuser'@'localhost' IDENTIFIED BY 'Str0ngPEd6';
mysql> GRANT ALL PRIVILEGES ON ghostdb. * TO 'ghostuser'@'localhost';
mysql> exit;

Step 5: Install Node.js

To install Ghost you need a supported Node.js version, so you can use the officially recommended Node.js v16.

First, add the Node.js repository running the following command:

$ sudo curl -sL | sudo -E bash

Once added, install the Node.js with the following command:

$ sudo apt-get install nodejs

Verify the installed version of Node.js running the following command:

node --version

You should see the following output:


Run the following command to install npm latest version globally:

$ sudo npm install npm@latest -g

npm is the node package manager used to install the Ghost-CLI on a system.

Verify the npm version with the following command:

npm --version

You should get the following output:


Step 6: Install Ghost-CLI on Ubuntu 22.04

Ghost-CLI is a command-line tool to help you get Ghost installed and configured for use, quickly and easily.

Run the following command to install.

$ sudo npm install -g ghost-cli@latest

Checking Ghost-CLI version:

$ ghost -v
Ghost-CLI version: 1.23.1

Step 7: Install Ghost

Once your server is setup and ghost-cli is installed you can install Ghost.

You can use the recommended location to install Ghost which is /var/www/ghost

$ sudo mkdir /var/www/ghost

Set up correct permissions.

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

Move inside the directory and install Ghost.

$ cd /var/www/ghost/
$ ghost install

You will see the output as follows.

 Checking system Node.js version - found v16.18.1
 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 v5.24.0
 Finishing install process
? Enter your blog URL:
? Enter your MySQL hostname: localhost
? Enter your MySQL username: ghostuser
? Enter your MySQL password: [hidden]
? Enter your Ghost database name: ghostdb
 Configuring Ghost
 Setting up instance
+ sudo useradd --system --user-group ghost
? Sudo Password [hidden]
+ sudo chown -R ghost:ghost /var/www/ghost/content
 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

Now you have to open a web browser and log in with the address and you will be able to create the admin user.

Ghost Welcome Page

Then you will see the control panel, and you will be able to use it.

Ghost Dashboard

Comments and Conclusion

Congratulations! You have successfully installed Ghost CMS on Ubuntu 22.04.

You should now visit the Ghost Help page and learn more about how to manage you Ghost installation.

Thanks for using this tutorial for installing the Ghost CMS on your Ubuntu 22.04 OS.

Leave a Reply

Your email address will not be published. Required fields are marked *