All posts

Blog

How to Install a Ghost Blog on a VPS with Ghost-CLI (Ubuntu Guide)

Illustrated cover for the Developers guide "How to Install a Ghost Blog on a VPS with Ghost-CLI (Ubuntu Guide)"

Ghost started as a simple, focused alternative to bigger blogging platforms, and it has grown into a full publishing tool with a clean editor, built-in newsletters and paid memberships. You can pay for managed Ghost hosting, but the software is open source, and installing it yourself on a VPS is well documented and surprisingly smooth thanks to the official Ghost-CLI tool.

This guide walks through how to install a Ghost blog on a VPS running Ubuntu, following the officially supported production stack: Nginx, MySQL 8, a supported Node.js LTS release and systemd.

Is self-hosted Ghost right for you?

Self-hosting makes sense if you:

  • Want full control over your server, data and theme files
  • Are comfortable with basic Linux commands over SSH
  • Are happy to run updates yourself every few weeks

If you'd rather not think about servers at all, managed hosting is the easier path. If you're still deciding between platforms, it's worth comparing how Ghost and WordPress handle themes, plugins and memberships before you commit.

What you'll need

  • A VPS running Ubuntu 22.04 or 24.04 with at least 1 GB of RAM (2 GB gives more breathing room for MySQL)
  • A domain name with an A record pointing to your VPS's IP address
  • A non-root user with sudo privileges
  • An email address for SSL certificate notices

Ghost-CLI has one quirk worth knowing in advance: don't name your Linux user ghost. The installer creates its own ghost system user to run the site, and a clash causes problems.

Step 1: Create a sudo user and update the server

If you're logged in as root, create a regular user first:

adduser yourname
usermod -aG sudo yourname
su - yourname

Then update packages:

sudo apt update && sudo apt upgrade -y

Step 2: Install Nginx and open the firewall

sudo apt install -y nginx
sudo ufw allow 'Nginx Full'

The Nginx Full profile opens ports 80 and 443. Make sure SSH (sudo ufw allow OpenSSH) is allowed too before enabling UFW.

Step 3: Install and prepare MySQL

sudo apt install -y mysql-server

Ghost connects to MySQL with a username and password, while Ubuntu's MySQL root account uses socket authentication by default. Ghost's own documentation handles this by setting a password for root. Open the MySQL shell:

sudo mysql

Then run, replacing the password with a strong one of your own:

ALTER USER 'root'@'localhost' IDENTIFIED WITH 'mysql_native_password' BY 'your-strong-password';
quit

During installation, Ghost-CLI uses these credentials to create a dedicated, limited MySQL user and database for your site, so root isn't used by Ghost day to day.

Step 4: Install Node.js

Ghost supports specific Node.js LTS versions only, and the supported list changes over time. Check the "supported Node versions" section of the official Ghost documentation, then install that version. The usual route on Ubuntu is the NodeSource repository; follow the current instructions on NodeSource's site for the version Ghost recommends. Afterward, confirm:

node -v
npm -v

Avoid installing Node.js through Ubuntu's default apt package, which is often too old for Ghost.

Step 5: Install Ghost-CLI

sudo npm install ghost-cli@latest -g

Ghost-CLI handles installation, configuration, SSL, updates and service management. Check it works with ghost help.

Step 6: Create the site directory

Ghost should live in its own folder under /var/www, owned by your user:

sudo mkdir -p /var/www/yoursite
sudo chown yourname:yourname /var/www/yoursite
sudo chmod 775 /var/www/yoursite
cd /var/www/yoursite

Replace yoursite and yourname with your own values. The directory must be empty before you run the installer.

Step 7: Run the installer

ghost install

Ghost-CLI checks your system, downloads Ghost and then asks a series of questions:

  1. Blog URL: enter the full address including the protocol, such as https://blog.yourdomain.com. Using https:// here tells Ghost to set up SSL.
  2. MySQL hostname: press Enter to accept localhost.
  3. MySQL username and password: use root and the password you set in step 3.
  4. Ghost database name: accept the suggested name or choose your own.
  5. Set up a ghost MySQL user? Yes. This creates the limited database user mentioned earlier.
  6. Set up Nginx? Yes. Ghost-CLI writes the Nginx config for you.
  7. Set up SSL? Yes, then enter your email. Your domain must already point to the server for this to succeed.
  8. Set up systemd? Yes, so Ghost runs as a service and starts at boot.
  9. Start Ghost? Yes.

When it finishes, visit https://blog.yourdomain.com/ghost/ to create your owner account. Do this right away, because the first person to reach that page becomes the site owner.

Step 8: Configure email

Ghost uses email in two ways, and they're set up differently:

  • Transactional email (staff invitations, password resets, member login links) needs SMTP settings in the config.production.json file in your site folder. Any reliable SMTP provider works.
  • Newsletters (bulk email to members) use a bulk email integration that you configure in the Ghost admin panel. Check Ghost's documentation for the currently supported provider.

After editing config.production.json, run ghost restart for changes to take effect.

Everyday Ghost-CLI commands

Run these from your site directory (/var/www/yoursite):

  • ghost ls lists Ghost installs on the server and their status.
  • ghost status shows whether this site is running.
  • ghost restart restarts the site after config changes.
  • ghost update updates Ghost to the latest version.
  • ghost log shows recent log output, useful when something breaks.
  • ghost doctor checks your setup for common problems.
  • ghost backup creates a backup of your content, members and settings.

Keeping your Ghost blog safe

  • Update regularly. Run ghost update every few weeks, and keep Ubuntu patched with apt upgrade.
  • Back up off the server. Use ghost backup or the export tool in the admin panel, and also copy the content folder, which holds your images and themes. Store copies somewhere other than the VPS.
  • Use SSH keys instead of password logins, as covered in our SSH keys guide.
  • Turn on staff two-factor verification in the admin settings if it isn't already enabled for your version.

Troubleshooting tips

  • SSL step fails: the DNS record probably hasn't propagated yet. Wait, then run ghost setup ssl from the site directory.
  • "Ghost was able to start but errored": run ghost log and look for database connection or permission errors.
  • Permission errors during updates: ghost doctor will usually point out the file or folder with the wrong ownership.

Wrapping up

Installing a Ghost blog on a VPS comes down to preparing a standard stack and letting Ghost-CLI do the heavy lifting. Once it's live, you have a fast, modern publishing platform with newsletters and memberships built in, on a server you control. Keep it updated, keep backups somewhere safe, and spend your time where it matters: writing.