Ghost is a focused publishing platform that takes installation seriously — it ships a CLI (ghost-cli) that owns the install, the systemd unit, Nginx config, and Let’s Encrypt certificate. This article runs through a clean Ghost install on Ubuntu 22.04 with MySQL 8 on the same host (or a private network), the things ghost setup does silently, and the operational details ghost-cli doesn’t cover — backups, mail transport, member-newsletter bounces, image storage.
How to verify
After install, the following checks should pass:
ghost ls
# Name Location Version Status URL Process Manager
# blog /var/www/ghost 5.x running https://blog.example.org systemd
curl -sI https://blog.example.org/ghost/api/admin/site/ | head -2
# HTTP/2 200
systemctl status ghost_blog-example-org
# Active: active (running) since ...
mysql -h127.0.0.1 -uroot -p -e "SHOW DATABASES;" | grep ghost
# ghost_prod
curl -s https://blog.example.org/ghost/api/admin/posts/?limit=1 \
-H "Authorization: Ghost $(your-admin-jwt)" | jq '.posts[0].title'
If ghost ls shows Status: stopped, run ghost log to see the last error — it’s usually a database connection or a missing Node major version.
What’s happening
Ghost is a Node.js application (Express + Knex + Bookshelf) backed by MySQL 8 in production. The official installer is ghost-cli, which puts everything under /var/www/ghost by default and writes a systemd unit named ghost_<slugified-url>. Inside that directory, config.production.json holds the database connection, the URL, the mail transport, and the file storage adapter; do not edit it by hand on a running install — use ghost config <key> <value> so the CLI revalidates and restarts the service correctly.
Content lives in MySQL except for two things: themes (Handlebars files under content/themes/) and member images / post feature images (under content/images/ by default). Theme upload is gzip tarballs from the admin; on disk they unpack into content/themes/<theme-name>/. The active theme is tracked in MySQL, so theme switches are atomic per-tenant.
Ghost’s member system is opinionated: members sign in with magic links sent by email (Stripe links them to subscriptions if you wire that up). The mail transport is critical — Ghost will refuse to send admin-invite or member-signin emails until you point it at SMTP credentials. The “Direct” transport is dev-only and most mailservers block it.
The procedure
-
Install Node 18 LTS (Ghost’s currently supported line), MySQL 8, and Nginx.
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo bash - sudo apt install -y nodejs mysql-server nginx sudo npm install -g ghost-cli@latest -
Provision MySQL and a database. Ghost 5 supports MySQL 8 only (not MariaDB):
DBPASS=$(openssl rand -hex 24) sudo mysql <<SQL CREATE DATABASE ghost_prod CHARACTER SET utf8mb4; CREATE USER 'ghost'@'127.0.0.1' IDENTIFIED BY '${DBPASS}'; GRANT ALL ON ghost_prod.* TO 'ghost'@'127.0.0.1'; FLUSH PRIVILEGES; SQL -
Create a non-root install user. ghost-cli refuses to install as root:
sudo adduser --disabled-password --gecos '' ghostuser sudo usermod -aG sudo ghostuser sudo mkdir /var/www/ghost && sudo chown ghostuser:ghostuser /var/www/ghost -
Install Ghost. Run as
ghostuser:sudo -iu ghostuser cd /var/www/ghost ghost install --url https://blog.example.org \ --db mysql --dbhost 127.0.0.1 --dbuser ghost \ --dbpass "${DBPASS}" --dbname ghost_prod \ --process systemd --no-promptghost-cli does the whole sequence: creates the install, generates the Nginx config, requests a Let’s Encrypt cert, installs the systemd unit, starts the service. On the first run it asks for the admin email; pass it on the command line if you script this.
-
Configure SMTP. No mail = no member sign-ins, no admin invitations. Point Ghost at the SMTP relay you operate (or a transactional API):
ghost config set mail.transport SMTP ghost config set mail.options.host smtp.example.org ghost config set mail.options.port 587 ghost config set mail.options.secure false ghost config set mail.options.auth.user 'ghost-blog' ghost config set mail.options.auth.pass "$(openssl rand -hex 16)" ghost config set mail.from '"Blog" <noreply@example.org>' ghost restartVerify with the admin > settings > email newsletter > “Send test email” button.
-
Switch content/images to S3 (optional but recommended). Install the adapter:
cd /var/www/ghost npm install ghost-storage-adapter-s3 mkdir -p content/adapters/storage ln -s ../../../node_modules/ghost-storage-adapter-s3 content/adapters/storage/s3Then:
ghost config set storage.active s3 ghost config set storage.s3.bucket blog-content-prod ghost config set storage.s3.region us-east-1 ghost config set storage.s3.acl public-read ghost config set storage.s3.assetHost https://cdn.example.org/ ghost restart -
Wire a backup. mysqldump nightly, plus
content/themes/andcontent/files/to your offsite target:cat <<'CRON' | sudo tee /etc/cron.d/ghost-backup 0 2 * * * ghostuser /usr/bin/mysqldump -h127.0.0.1 -ughost -p$(cat /home/ghostuser/.ghost-dbpass) ghost_prod | gzip > /var/backups/ghost/ghost-$(date +\%F).sql.gz 30 2 * * * ghostuser /usr/bin/tar -czf /var/backups/ghost/themes-$(date +\%F).tar.gz -C /var/www/ghost/content themes CRON
Common pitfalls
- ghost-cli pins itself to a supported Node major. Bump Node ahead of Ghost’s supported line and
ghost updatewill refuse to run. Always check the Ghost compatibility matrix beforeapt upgrade nodejs. - Direct mail transport is
mail.transport: Direct— leaving that in production silently bounces every member invitation. content/images/outgrows the system disk faster than expected on member-heavy blogs (feature images, gravatars). Either move it to S3 or pin it on its own volume from day one.ghost updateruns migrations in the same transaction as the swap; if MySQL is under load and times out, the install ends in a half-state. Run updates from a maintenance window.- Behind a non-Ghost-managed Nginx (your own LB), set
urlto the public URL andserver.hostto127.0.0.1— otherwise Ghost generates absolute admin URLs to the wrong host.
For publications that run on Ghost, Stack Harbor operates the platform — Node/MySQL kept in the supported window, mail transport monitored for bounces, content/images on object storage with lifecycle, backups verified by restore — so the editorial team only sees the publishing UI. That model lives under managed operations, with related notes in the knowledge base.