Website Vidya
Linux & ServersStep-by-Step Guide

How to Install Ghost on Ubuntu 24.04

Step-by-step tutorial on how to install Ghost on Ubuntu 24.04 LTS with Node.js, MySQL/MariaDB, Nginx, and Ghost-CLI with automated Let's Encrypt SSL.

RR
Rajesh RayLead Systems Educator
Published:
7 min read
PDF Cheat Sheet
How to Install Ghost on Ubuntu 24.04
AI Executive SummaryWebsiteVidya AI

7 min read

Step-by-step tutorial on how to install Ghost on Ubuntu 24.04 LTS with Node.js, MySQL/MariaDB, Nginx, and Ghost-CLI with automated Let's Encrypt SSL.

Key Highlights
  • Prerequisites and Supported Releases
  • Step 1: Updating System Repositories and Installing Nginx
  • Step 2: Installing and Securing MySQL Database Server
Grounded in full engineering runbookWebsiteVidya AI Engine

Interactive Builder for this Guide

Build your custom nginx syntax (How to Install Ghost on Ubuntu 24.04)

Generated Config Output
server {
    listen 80;
    listen [::]:80;
    server_name app.example.com;
    return 301 https://$host$request_uri;
}

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name app.example.com;

    ssl_certificate /etc/letsencrypt/live/app.example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/app.example.com/privkey.pem;

    add_header X-Frame-Options "SAMEORIGIN" always;
    add_header X-Content-Type-Options "nosniff" always;
    add_header Referrer-Policy "strict-origin-when-cross-origin" always;

    gzip on;
    gzip_types text/plain text/css application/json application/javascript application/xml;

    location / {
        proxy_pass http://127.0.0.1:3000;
        proxy_http_version 1.1;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }
}
Production Nginx reverse proxy -> 127.0.0.1:3000 for app.example.com.
Flag-by-Flag Breakdown
server_nameBinds this virtual host to app.example.com
return 301 https://...Redirects all plain HTTP requests permanently to TLS/HTTPS
proxy_pass http://127.0.0.1:3000Forwards HTTP + WebSocket requests to local application server
X-Content-Type-Options / X-Frame-OptionsProtects users against MIME sniffing and clickjacking

Ghost is a modern, open-source content management system and publishing platform engineered specifically for professional bloggers, independent journalists, media organizations, and digital subscription publications. Built on Node.js and featuring a minimalist card-based rich-text editor, built-in email newsletters, Stripe member subscription billing, native SEO tags, and automated RSS syndication, Ghost delivers exceptional publishing speed without the bloat of traditional CMSs.

Self-hosting Ghost on an Ubuntu Linux server provides complete ownership of your subscriber lists, audience relationships, and content archives without platform transaction cuts. Learning how to install ghost on ubuntu 24.04 enables creators, publishers, and businesses to run a fast, modern digital publication with built-in subscription billing, email newsletters, and rich markdown editing.

In this step-by-step tutorial, we demonstrate how to install Ghost on Ubuntu 24.04 LTS (Noble Numbat). We cover installing Nginx, configuring the MySQL database server, installing the supported Node.js LTS runtime via NodeSource, deploying the official Ghost-CLI command-line tool, setting up directory permissions in /var/www/ghost, executing the automated ghost install installer, configuring systemd daemons, and provisioning Let's Encrypt SSL.

Advertisement

Prerequisites and Supported Releases

This guide is thoroughly verified on Ubuntu 24.04 LTS (Noble Numbat). The instructions apply cleanly to cloud instances (AWS EC2, Google Compute Engine, DigitalOcean, Hetzner), bare-metal servers, and local virtual machines.

Before proceeding, ensure you have the following requirements satisfied:

  • A cloud server or VPS running Ubuntu 24.04 LTS with at least 1 GB of RAM (2 GB recommended).
  • A non-root user account configured with administrative sudo privileges.
  • A registered domain name (e.g., journal.example.com) pointed to your server's public IP address.
  • Open incoming network ports 80 and 443 in your cloud firewall.

Step 1: Updating System Repositories and Installing Nginx

Ghost officially supports and recommends Nginx as its frontend web server and reverse proxy. Nginx handles client SSL termination, HTTP/2 compression, static file caching, and transparent request forwarding to the Node.js application process.

First, refresh your local APT repository index and upgrade installed packages to their latest stable security releases.

Advertisement

Install Nginx, curl, and essential system utilities using the APT package manager.

Enable and verify that the Nginx service is running and configured to launch automatically upon system boot.

# Update APT package repositories
sudo apt update && sudo apt upgrade -y

# Install Nginx and prerequisite tools
sudo apt install -y nginx curl wget git build-essential

# Enable and start Nginx service
sudo systemctl enable --now nginx
sudo systemctl status nginx --no-pager

Step 2: Installing and Securing MySQL Database Server

Ghost officially mandates MySQL 8.0 as its production relational database engine. While development setups can use SQLite, production Ghost instances require MySQL for concurrent write performance, relational data integrity, and automated schema migrations.

Install the mysql-server package using APT.

Advertisement

Log into the MySQL root shell and verify that native password authentication is configured for administrative access. This allows Ghost-CLI to connect and automatically provision the publication database.

Ghost-CLI will automatically prompt for database user creation or you can provision a dedicated ghost database and user in advance.

# Install MySQL database server
sudo apt install -y mysql-server

# Enable and verify MySQL service
sudo systemctl enable --now mysql

# Access MySQL shell to set root password authentication
sudo mysql -e "ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'StrongRootPass123!'; FLUSH PRIVILEGES;"

Step 3: Installing Supported Node.js LTS Runtime

Ghost is engineered entirely on Node.js and requires an active long-term support (LTS) release, such as Node.js 18.x or Node.js 20.x. Running unsupported Node.js odd-numbered releases (like Node 19 or Node 21) can cause runtime crashes or package incompatibility.

Add the official NodeSource repository to your Ubuntu system to obtain verified LTS binaries.

Install Node.js along with npm using the APT package manager.

Verify that both the node and npm binaries are available on your system path and match recommended versions.

# Add NodeSource repository for Node.js 18.x or 20.x
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -

# Install Node.js
sudo apt install -y nodejs

# Verify installed Node and npm versions
node -v
npm -v

Step 4: Installing Ghost-CLI Globally via npm

Ghost-CLI is the official command-line management tool designed by the Ghost foundation. It handles downloading release archives, configuring MySQL databases, generating Nginx server blocks, configuring systemd unit files, setting up free SSL certificates via Let's Encrypt, and executing seamless one-click updates.

Install ghost-cli globally using npm with administrative privileges.

Verify that the ghost command is available on your system path and check the CLI utility version.

# Install Ghost-CLI globally
sudo npm install -g ghost-cli@latest

# Verify Ghost-CLI version
ghost version

Step 5: Creating Directory Structure and Setting Permissions

Ghost-CLI strictly enforces security boundaries and mandates that installations must never occur in the root user directory or under the root user account.

Create the dedicated web root directory at /var/www/ghost.

Assign ownership of the directory to your non-root user account (e.g., $USER) with standard group permissions.

Set directory permissions so that Ghost-CLI can download packages, create subdirectories for themes and images, and manage configuration files without permission conflicts.

# Create Ghost web root directory
sudo mkdir -p /var/www/ghost

# Assign directory ownership to your active non-root user
sudo chown $USER:$USER /var/www/ghost

# Set correct permissions
sudo chmod 775 /var/www/ghost

Step 6: Executing Ghost Installation via Ghost-CLI

Navigate into /var/www/ghost and execute the automated ghost install command as your regular non-root user.

The interactive installer guides you through initial setup questions and automates all heavy infrastructure provisioning:

Blog URL: Enter your public domain name prefixed with HTTPS (e.g., https://journal.example.com).

MySQL hostname: Press Enter to accept the default localhost.

MySQL username / password: Enter root and your MySQL root password. Ghost-CLI will automatically provision a dedicated ghost_production database and a secure unprivileged database user.

Ghost user / Nginx / SSL: Enter Y to let Ghost-CLI configure the ghost system user, generate Nginx reverse proxy configurations, register a systemd service daemon, and obtain a free Let's Encrypt SSL certificate.

# Change into Ghost directory
cd /var/www/ghost

# Run the automated installer
ghost install

Step 7: Configuring UFW Firewall for Web Traffic

Allow incoming web traffic on HTTP port 80 and HTTPS port 443 through Ubuntu's Uncomplicated Firewall (UFW). Port 80 is required for initial ACME certificate verification and automatic HTTP-to-HTTPS redirects, while port 443 serves encrypted visitor traffic.

Allow the pre-configured Nginx Full profile in UFW to open both ports simultaneously.

Confirm active firewall status and ensure that SSH access remains permitted so you are not locked out of the server.

# Allow HTTP and HTTPS traffic in UFW
sudo ufw allow 'Nginx Full' comment 'Allow Nginx HTTP and HTTPS'

# Verify firewall rules
sudo ufw status numbered

Step 8: Accessing Ghost Admin and Setting Up Your Publication

Once Ghost-CLI finishes installation and starts the Node.js daemon, open your web browser and navigate to https://journal.example.com/ghost.

The initial setup screen prompts you to create your publication's administrator account.

Enter your Site title, your full Name, Email address, and a strong administrative password.

Click Create account & start publishing to open the Ghost management dashboard, where you can write stories, configure themes, and manage email newsletter lists.

From the settings panel, you can connect your Stripe account to monetize paid memberships, upload custom brand logos, customize navigation links, and invite staff writers.

Admin Setup URL: https://journal.example.com/ghost
Initial Screen: 'Create your account'
Details: Site title, Name, Email, Password
Features: Markdown/Card Editor, Member Subscriptions, Newsletters, Stripe Billing

Troubleshooting and Common Errors

When configuring Ubuntu servers, unexpected permission errors, network timeouts, or lock contention can occur. Review these common issues and verified resolutions:

Ghost-CLI fails with 'ProcessError: EACCES: permission denied'

Resolution: Ensure you are not running ghost install as root. Verify directory ownership of /var/www/ghost belongs to your non-root user: sudo chown -R $USER:$USER /var/www/ghost.

Ghost start fails: 'Database connection failed'

Resolution: Ensure MySQL is running: sudo systemctl status mysql. Verify that MySQL allows password authentication. Check credentials in /var/www/ghost/config.production.json.

Let's Encrypt SSL acquisition fails during installation

Resolution: Confirm that your domain's DNS A record points directly to your server's public IP address before running ghost setup ssl. Ensure ports 80 and 443 are not blocked by external firewalls.

Security Best Practices and Hardening

Never execute the Ghost blogging application under the root user account; use the dedicated unprivileged 'ghost' system user.

Store uploaded media and database backups securely, and ensure /var/www/ghost/config.production.json permissions are restricted to user-only read (chmod 600).

Enable Two-Factor Authentication (2FA) for your Ghost Staff Admin accounts.

Keep Ghost updated to the latest minor versions using 'ghost update' to patch security vulnerabilities in Node.js modules.

Deepen your Linux system administration skills with our related production-tested guides:

Authoritative References and Official Documentation

Frequently Asked Questions

Quick answers to common questions and configurations

3 FAQs
Navigate to your Ghost directory (cd /var/www/ghost) and execute ghost update. Ghost-CLI automatically backs up your configuration, updates dependencies, runs database migrations, and restarts the service.
Yes. In Ghost Admin > Settings > Email newsletter, integrate with Mailgun (or another SMTP provider) by providing your API key to send automated bulk newsletters to your subscribers.
In /var/www/ghost, execute ghost status to check daemon health, or ghost log to view real-time application logs.
RR
Written byVerified Author

Rajesh Ray

I’m Rajesh Rai, a full-stack developer, Linux administrator, and technology enthusiast passionate about making complex technology easier to understand and use.

SPAM-FREE MODERATED DISCOURSE

Join the Conversation & Perspective

Have thoughts, counterpoints, or reflections on this story? Engage directly with fellow readers and editorial contributors.

AT
MP
JV
+2

No comments on this guide yet. Be the first to share your thoughts or ask a question!

Recommended Reading10 Guides

Related Technical Guides

Tested runbooks, server administration walkthroughs, and troubleshooting guides

Featured Infrastructure PartnerUp to 75% OFF + 3 Months Free

Supercharge Your Linux & Cloud Workloads with Hostinger

Deploy high-speed NVMe KVM VPS, Docker containers, and LiteSpeed-accelerated WordPress servers in under 60 seconds with full root access, dedicated IPv4, and 24/7 technical support.

Pure NVMe SSD StorageFull Root Access & SSHFree Domain & Unlimited SSL99.9% Uptime SLA
Plans from$2.99/mo
Claim Hostinger DealAffiliate link • Special discount applied at checkout