Databases

How to Install Ghost CMS on Ubuntu VPS with MySQL 8 and Nginx (Ultimate Publisher Guide)

How to Install Ghost CMS on Ubuntu VPS with MySQL 8 and Nginx (Ultimate Publisher Guide) - CpanelFree Guide
Written by Blog

Why Professional Creators and Media Outlets Choose Ghost CMS

While WordPress remains the dominant CMS worldwide, modern creators, independent publishers, and digital media organizations frequently seek platforms engineered specifically for long-form publishing, paid member subscriptions, native email newsletters, and extreme speed. Ghost CMS is a lightning-fast, open-source publishing engine built on Node.js. Powered by the V8 JavaScript runtime and a clean markdown/rich-text editor, Ghost delivers page loads up to 1,900% faster than traditional PHP-based CMS platforms.

While managed Ghost(Pro) hosting charges $30 to $200+ monthly as subscriber counts scale, self-hosting Ghost CMS on an Ubuntu Cloud VPS gives you unlimited members, zero subscription revenue commissions, custom Handlebars themes, and total database sovereignty for just the raw VPS server cost.

In this comprehensive enterprise tutorial, we will configure Node.js LTS, MySQL 8, and Ghost-CLI on Ubuntu 24.04/22.04 LTS, provision a dedicated production database, automate SSL certificate generation, and configure transactional email deliverability via Mailgun or custom SMTP.

Step 1: Preparing Server Prerequisites & Installing Node.js LTS

Ghost requires an unprivileged system user, active Node.js LTS (v18.x or v20.x), Nginx web server, and MySQL 8.0:

# Update package repositories and install core dependencies
sudo apt update && sudo apt install -y curl git nginx certbot python3-certbot-nginx mysql-server

# Install official NodeSource Node.js 20 LTS repository
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt install -y nodejs

# Install the official Ghost-CLI management utility globally
sudo npm install -g ghost-cli@latest

Step 2: Installing and Hardening MySQL 8.0 for Ghost

Ghost requires native MySQL 8.0 for relational schema management and member subscription handling. Create a dedicated database and user with native password authentication:

# Access MySQL root console
sudo mysql << 'EOF'
CREATE DATABASE ghost_production DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'ghost_user'@'127.0.0.1' IDENTIFIED WITH mysql_native_password BY 'UltraSecretGhostPass2026!';
GRANT ALL PRIVILEGES ON ghost_production.* TO 'ghost_user'@'127.0.0.1';
FLUSH PRIVILEGES;
\q
EOF

Step 3: Creating Production Directory and Ghost System User

Ghost-CLI strictly prohibits running installations as the root user. Create a dedicated administrative user or execute under a standard sudo user:

# Create webroot directory
sudo mkdir -p /var/www/ghost
sudo chown -R $USER:$USER /var/www/ghost
sudo chmod 775 /var/www/ghost

# Navigate to project root
cd /var/www/ghost

Step 4: Automated Ghost Production Installation via Ghost-CLI

Ghost-CLI automates the entire stack setup—downloading Ghost core, running database migrations, configuring systemd daemons, generating Nginx virtual hosts, and provisioning Let’s Encrypt SSL certificates:

# Launch interactive Ghost installation wizard
ghost install

Ghost-CLI Configuration Prompts:

  • Blog URL: https://publish.example.com (Must include https://)
  • MySQL hostname: 127.0.0.1
  • MySQL username: ghost_user
  • MySQL password: UltraSecretGhostPass2026!
  • Ghost database name: ghost_production
  • Set up a ghost mysql user? No (We already configured it)
  • Set up Nginx? Yes
  • Set up SSL? Yes (Enter your administrative email for Let’s Encrypt notices)
  • Set up systemd? Yes
  • Start Ghost? Yes

Step 5: Configuring Transactional Email Delivery for Newsletters

Ghost features native email newsletter distribution. Configure your SMTP or Mailgun credentials in /var/www/ghost/config.production.json:

"mail": {
  "transport": "SMTP",
  "options": {
    "service": "Mailgun",
    "host": "smtp.mailgun.org",
    "port": 587,
    "secure": false,
    "auth": {
      "user": "[email protected]",
      "pass": "YourMailgunSmtpKeyHere"
    }
  }
}

Apply configuration changes by running ghost restart.

Ghost CMS Performance & Architectural Matrix

Layer Component Operational Role Advantage
Application Engine Node.js V8 Runtime Ghost Core & API Non-blocking asynchronous I/O
Database Engine MySQL 8.0 InnoDB Posts, Members, Payments ACID transaction safety
Edge Reverse Proxy Nginx + SSL Static asset cache & HTTP/2 Sub-25ms response speeds

Essential Ghost-CLI Management Commands

  • ghost status: Inspect active port, process ID, and systemd daemon health.
  • ghost restart: Restart Node.js application process without dropping web connections.
  • ghost update: Automatically backup database and upgrade Ghost core to the newest release.
  • ghost log -f: Stream real-time access and error logs.

Automating Ghost Backups with Ghost-CLI and Crontab

While Ghost stores published images and uploaded media assets under /var/www/ghost/content/images/, all subscriber lists, post revisions, and member settings live in MySQL. Automate daily offsite backups with this automated cron script:

# Automated Ghost Backup Script (/usr/local/bin/backup-ghost.sh)
#!/bin/bash
set -e
DATE=$(date +%Y%m%d_%H%M%S)
BACKUP_DIR="/var/backups/ghost/$DATE"
mkdir -p $BACKUP_DIR

# Export MySQL database
mysqldump -u ghost_user -p'UltraSecretGhostPass2026!' ghost_production | gzip > $BACKUP_DIR/ghost_db.sql.gz

# Archive uploaded images and themes
tar -czvf $BACKUP_DIR/ghost_content.tar.gz -C /var/www/ghost/content images themes

# Prune old archives (> 30 days)
find /var/backups/ghost/ -type d -mtime +30 -exec rm -rf {} +
echo "Ghost automated backup completed successfully!"

Ghost Troubleshooting & Maintenance Playbook

Issue / Symptom Root Cause Resolution Action
Ghost process crashing on start Node.js version mismatch or port 2368 conflict Verify with ghost doctor and check ghost log
502 Bad Gateway on publish URL Systemd daemon stopped or memory limit reached Run ghost restart and inspect systemctl status ghost_*
Newsletter emails failing to deliver Missing Mailgun API key or unverified domain DNS Verify SPF, DKIM, and MX records in Mailgun portal

Launch Lightning-Fast Ghost CMS on CpanelFree Cloud VPS

Scale your publication and newsletter with pure NVMe storage, dedicated memory, and 100% free hosting and VPS options.

Get Free Cloud Hosting Today →

Deploy Fast, Reliable Web Hosting on CpanelFree

Get genuine cPanel control, unmetered NVMe SSD storage, and free AutoSSL at $0 cost forever.

Claim Free Hosting Account

About the author

Blog

DevOps architect and Linux sysadmin specializing in server hardening, OpenLiteSpeed performance optimization, and free cloud hosting infrastructure.

Leave a Comment