Install Ghost Blog Platform on Ubuntu

By Anurag Singh

Updated on Feb 14, 2025

Install Ghost Blog Platform on Ubuntu

In this tutorial, we'll learn how to install Ghost Blog Platform on Ubuntu 24.04 server.

Ghost is a modern, high-performance blogging platform built on Node.js, designed to empower content creators with simplicity, speed, and flexibility. We'll walk you through every step of installing Ghost on Ubuntu 24.04, from setting up the necessary environment and dependencies to configuring MySQL for a robust production database.

Whether you're a developer looking to explore a cutting-edge Node.js solution or an IT professional seeking a reliable and scalable blogging platform, this tutorial will equip you with the knowledge to get Ghost up and running seamlessly.

Below is a detailed, step-by-step tutorial on installing and configuring the Ghost Blog Platform on Ubuntu 24.04. This guide is written with a technical audience in mind, so expect in-depth explanations for each command and configuration choice.

Prerequisites:

Install Ghost Blog Platform on Ubuntu

1. Preparing Your Ubuntu Environment

Before you begin, log in to your Ubuntu server with a user that has sudo privileges. It’s best to work on a fresh or updated system, so let’s update our package lists and upgrade installed packages.

sudo apt update && sudo apt upgrade -y

What this does:

  • sudo apt update retrieves the latest package lists from repositories.
  • sudo apt upgrade -y installs the newest versions of installed packages.
  • The -y flag automatically confirms installation prompts.

2. Installing Required Dependencies

Ghost is a Node.js-based application and also relies on a web server (typically Nginx) to handle requests and SSL termination. Let’s install these dependencies.

a. Install Nginx

sudo apt install nginx -y

Explanation:

Nginx will act as a reverse proxy for Ghost. It will receive incoming HTTP/HTTPS requests and forward them to the Node.js process running Ghost.

b. Install Node.js

Ghost requires a specific version of Node.js. At the time of this guide, Node.js 20.x is a stable LTS version that is well supported by Ghost. To install it, use the NodeSource repository:

curl -sL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt install nodejs -y

Explanation:

  • The curl command downloads the setup script for Node.js 18.x.
  • Piping it to bash runs the script which adds the NodeSource repository to your system.
  • Installing nodejs brings both Node.js and npm (the Node package manager).

Note: Ghost’s documentation recommends a particular Node.js version range. Always verify with the official Ghost docs in case of future changes.

3. Installing Ghost-CLI Globally

The Ghost CLI is a command-line tool that automates much of the installation and configuration process.

sudo npm install -g ghost-cli@latest

What’s happening:

  • npm install -g installs the package globally so you can run the ghost command from any directory.
  • The Ghost CLI will handle creating systemd services, configuring Nginx, setting up SSL, and more.

4. Install and create MySQL Database

If you haven't installed MySQL already, start by updating your package lists and installing MySQL:

sudo apt install mysql-server -y

Explanation:

This installs the MySQL server software on your Ubuntu system.

Run the MySQL secure installation script to improve the security of your MySQL setup:

sudo mysql_secure_installation

Follow these steps during the prompt:

  • Set up the VALIDATE PASSWORD PLUGIN (optional): This can enforce password strength.
  • Change the root password: If prompted, set a strong password for the MySQL root user.
  • Remove anonymous users, disallow root login remotely, remove test databases: Answer “Y” to these to secure your installation.

Why this is important:

Securing MySQL ensures that only authorized users can access your database and that your server isn’t vulnerable to common exploits.

Creating a Dedicated MySQL Database and User for Ghost

Now, log in to the MySQL shell as the root user:

sudo mysql -u root -p

Once you’re in the MySQL prompt, run the following commands:

-- Create a new database for Ghost
CREATE DATABASE ghost_production;

-- Create a new user (replace 'ghostuser' and 'YourStrongPassword' with your preferred username and a strong password)
CREATE USER 'ghostuser'@'localhost' IDENTIFIED BY 'YourStrongPassword';

-- Grant the new user full privileges on the ghost_production database
GRANT ALL PRIVILEGES ON ghost_production.* TO 'ghostuser'@'localhost';

-- Apply the changes immediately
FLUSH PRIVILEGES;

-- Exit the MySQL shell
EXIT;

5. Creating a Dedicated Directory for Ghost

For best practices and security, install Ghost in its own directory. We’ll use /var/www/ghost as the installation folder. If you prefer, you can create a dedicated system user (e.g., ghost) for running the blog, but for this tutorial we’ll adjust ownership of the directory to your current user.

sudo mkdir -p /var/www/ghost
sudo chown $USER:$USER /var/www/ghost

Explanation:

  • mkdir -p ensures the target directory exists.
  • chown $USER:$USER changes the directory’s owner and group to your current user (replace $USER with the appropriate username if needed).
  • Running Ghost under a non-root user enhances security.

6. Configuring the Firewall

If you have UFW (Uncomplicated Firewall) enabled on your Ubuntu server, you must allow traffic on HTTP and HTTPS ports. Use the following commands:

sudo ufw allow 'Nginx Full'
sudo ufw reload

7. Running the Ghost Installer

Now that prerequisites are in place, navigate to the installation directory and use Ghost CLI to install Ghost.

cd /var/www/ghost
ghost install

What to Expect During Installation:

Domain Name Prompt:

The installer will ask for your domain name (e.g., example.com). If you don’t have one yet, you can use your server’s IP address, though SSL and other domain-specific configurations may be skipped.

SSL Setup:

If you provide a valid domain that points to your server, Ghost CLI will attempt to set up SSL automatically using Let’s Encrypt. Make sure that ports 80 and 443 are open (we’ll address firewall configuration later).

Database Selection:

Ghost uses SQLite by default for smaller blogs, but you can configure MySQL or PostgreSQL if you expect higher traffic or need additional features. The installer will guide you if you choose a different database. For most users starting out, SQLite is sufficient.

Configuration Files and Service Setup:

Ghost CLI writes configuration files (located in /var/www/ghost/config.production.json) and creates a systemd service so that Ghost starts automatically on boot. You don’t need to manage these manually.

Deep Insight:

The ghost install command checks for system compatibility, sets up file permissions, configures Nginx as a reverse proxy (creating a configuration file in /etc/nginx/sites-available/ghost), and registers Ghost as a service. This streamlines what would otherwise be several manual steps.

8. Post-Installation: Managing Your Ghost Instance

Once the installation completes successfully, Ghost should be running as a background service. You can manage Ghost using the CLI commands:

Check Status:

ghost status

Start Ghost:

ghost start

Stop Ghost:

ghost stop

Restart Ghost:

ghost restart

View Logs:

ghost log

Understanding the Management Commands:

These commands interact with the systemd service that was created during installation. They provide a simple way to control the blog process without manually interfacing with system services.

9. Accessing Your Ghost Blog

After installation and configuration, open your web browser and navigate to the domain name or IP address you provided during the setup. You should see the Ghost setup screen where you can complete the admin configuration (set up your account, title, etc.). 

https://yourdomain.com/ghost

Tips:

  • If using a domain, ensure that your DNS settings are correctly pointed to your server’s IP address.
  • If you opted for SSL, your browser will use HTTPS automatically.

10. Troubleshooting and Further Customization

Common Issues & Solutions:

Port Conflicts: If another service is using port 80 or 443, Nginx may fail to start. Identify conflicting services and disable or reconfigure them.

Node.js Version Mismatch: Ghost supports specific Node.js versions. If you see errors related to Node.js, verify your version with node -v and compare it against the Ghost documentation.

File Permissions: Ghost requires proper read/write permissions in its installation directory. If you encounter permission errors, double-check directory ownership.

Customizing Ghost

Themes: Ghost supports custom themes. Once your blog is up and running, you can install new themes from the Ghost Admin interface.

Integrations: Ghost offers many integrations (like Zapier, Google Analytics, etc.). Explore these options to extend your blog’s functionality.

Backups: Regularly back up your content and configuration files. Ghost CLI and your database (whether SQLite or MySQL) should be part of your backup routine.

In this tutorial, we've learnt how to install Ghost Blog Platform on Ubuntu 24.04 server. By following these steps, you now have a modern, Node.js-based Ghost blog platform running on Ubuntu 24.04. This setup is optimized for both performance and security, and Ghost CLI takes care of much of the heavy lifting so you can focus on creating content.

If you have any questions or run into issues, the official Ghost documentation and community forums are excellent resources for further help. Enjoy your new blogging platform!