How to Install Ghost CMS on Ubuntu 24.04

Ghost CMS is a blasing fast, modern publishing platform for building professional blogs and newsletters. It’s built on Node.js and designed to be simple, secure, and extendable. In this guide, you’ll learn how to install and deploy Ghost CMS on Ubuntu 24.04 using Nginx, MySQL, and the official Ghost CLI.

For teams managing multiple servers or performing repeatable setups, CloudRay can help automate the installation and deployment of Ghost CMS using Bash scripts, without needing to SSH into each server manually.

Contents

Update the System & Create a Ghost User

To begin, update your system’s package index and create a dedicated user for managing Ghost. This helps isolate your CMS from the root user and enhances security.

  1. Update the APT package index
sudo apt update
  1. Create a non-root user named ghost
sudo adduser ghost

When prompted, enter a strong password and optionally fill in the user details.

  1. Grant ghost user sudo privileges
sudo adduser ghost sudo
  1. Verify the Java installation
su - ghost

From this point on, you will operate as the ghost user for the remainder of the installation.

Install and Configure Nginx

Ghost CMS uses Nginx as a reverse proxy to serve your site over HTTP or HTTPS.

  1. Install Nginx
sudo apt install nginx -y
  1. Allow Nginx through the firewall
sudo ufw allow 'Nginx Full'
  1. Confirm Nginx is running
sudo systemctl status nginx

You should see output showing that the Nginx service is active (running)

Confirm Nginx status

if it’s not active and running, you can start the nginx service

sudo systemctl start nginx

Install and Configure MySQL

Ghost CMS uses MySQL to store all its content and metadata. Let’s install and set up a new database for Ghost.

  1. Install MySQL Server
sudo apt install mysql-server -y
  1. Access the MySQL shell
sudo mysql
  1. Create a dedicated database and user for Ghost
CREATE USER 'ghostuser'@'localhost' IDENTIFIED BY 'your_strong_password';
CREATE DATABASE ghostdb;
GRANT ALL ON ghostdb.* TO 'ghostuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;

You can replace the your_strong_password with a secure password

Looking to automate your MySQL setup? Check out this guide on automating MySQL installation in CloudRay.

Install Node.js and Ghost CLI

Ghost CMS is built on Node.js, so you’ll need to install Node and the Ghost CLI to manage your Ghost instance.

  1. Install Node.js and npm
sudo apt install nodejs npm -y
  1. Install Ghost CLI globally using npm
sudo npm install -g ghost-cli@latest
  1. Verify the installation
ghost --version

This command confirms that Ghost CLI was installed correctly. You should see the version number in the output.

Create Ghost Directory and Install Ghost

Now that your environment is ready, it’s time to create a directory where Ghost will live and set the appropriate permissions.

  1. Create the Ghost installation directory
sudo mkdir -p /var/www/ghost
  1. Change the directory ownership to the ghost user
sudo chown ghost:ghost /var/www/ghost
  1. Give the right permissions to the directory
sudo chmod 775 /var/www/ghost
  1. Navigate to the Ghost directory
cd /var/www/ghost/
  1. Install Ghost using the CLI
ghost install

The CLI will guide you through configuration steps like setting your blog URL, configuring MySQL credentials, and setting up Nginx and SSL.

Screenshot showing Ghost setup

If all dependencies are met, Ghost will install and start automatically.

Screenshot showing Ghost setup

In this case you can visit the Ghost CMS website with your domain.

Screenshot showing Ghost setup

Manually setting up the Ghost CMS across multiple servers can be time-consuming, especially when repeating the same steps on each server. [CloudRay] simplifies this process by allowing you to create reusable Bash scripts that can be executed remotely across your infrastructure.

With CloudRay, you can automate the entire Ghost CMS setup:

  • Create and configure the ghost user
  • Install required packages like Node.js, Nginx, and MySQL
  • Set up the Ghost CLI and automate the Ghost installation
  • Configure Nginx reverse proxy and SSL

Before you automate the installation process, connect your server to CloudRay using the CloudRay agent. This allows you to run bash scripts directly from the dashboard without SSH access.