Log inSign up

Self-hosting Ghost on an Ubuntu server

Ghost is supported on Ubuntu with Nginx, MySQL 8 and the Node.js LTS release that Ghost supports, all driven by Ghost-CLI. Install those three, create a sudo user that is not called ghost, then run ghost install in an empty /var/www directory and answer its questions; it configures Nginx, HTTPS and a systemd service for you.

Topic: Websites, CMS and shops · Tested on: Ubuntu 24.04 and 22.04 · Updated 2026-12-03

What does Ghost need on the server?

Ghost-CLI expects a specific stack and checks it before installing, so prepare it exactly:

  • Ubuntu 24.04 or 22.04 (the Ubuntu 24.04 image is a good fit).
  • Nginx as the front web server.
  • MySQL 8 as the database. MariaDB is not supported for production Ghost.
  • A Node.js version from Ghost's supported list, currently the active LTS line.
  • A sudo user whose name is not ghost, because Ghost-CLI creates a system user with that name.
  • At least 1 GB of RAM; add a swap file on 1 GB plans so builds and updates do not run out of memory.

Point blog.example.net (or your root domain) at the server first, as in DNS records, because the installer requests a certificate during setup.

How do you install Nginx, MySQL and Node.js?

Update the system, install Nginx and MySQL from Ubuntu, then add Node.js from the NodeSource repository using the major version Ghost lists as supported (22 at the time of writing).

sudo apt update && sudo apt -y upgrade
sudo apt install -y nginx mysql-server ca-certificates curl gnupg
sudo ufw allow OpenSSH
sudo ufw allow 'Nginx Full'
sudo ufw enable

sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
NODE_MAJOR=22
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | sudo tee /etc/apt/sources.list.d/nodesource.list
sudo apt update && sudo apt install -y nodejs
node -v && npm -v && mysql --version

Ubuntu ships MySQL 8.0 in both supported releases. If you install Node.js another way, such as through a version manager, Ghost-CLI may not find it when it runs under sudo; the system package avoids that.

How do you prepare the MySQL database?

Create a dedicated database user rather than handing Ghost the root account.

sudo mysql_secure_installation
sudo mysql
CREATE DATABASE ghost_prod CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci;
CREATE USER 'ghostdb'@'localhost' IDENTIFIED BY 'another-long-random-password';
GRANT ALL PRIVILEGES ON ghost_prod.* TO 'ghostdb'@'localhost';
FLUSH PRIVILEGES;
EXIT;

MySQL listens only on localhost by default on Ubuntu; confirm with ss -tlnp | grep 3306. On a 1 GB plan, lower memory use by setting innodb_buffer_pool_size = 128M and performance_schema = OFF in /etc/mysql/mysql.conf.d/mysqld.cnf, then restart MySQL.

How do you run the Ghost installer?

Install Ghost-CLI globally, create the site directory owned by your user, and run the installer from inside it as that user (not as root).

sudo npm install -g ghost-cli@latest
ghost --version
sudo mkdir -p /var/www/ghost
sudo chown deploy:deploy /var/www/ghost
sudo chmod 775 /var/www/ghost
cd /var/www/ghost
ghost install

The installer asks a series of questions. Typical answers:

  • Blog URL: https://blog.example.net (include https).
  • MySQL hostname: localhost; username ghostdb, its password, and database name ghost_prod.
  • Set up Nginx: yes. Set up SSL: yes, with your email for certificate notices.
  • Set up systemd: yes. Start Ghost: yes.

When it finishes, open https://blog.example.net/ghost/ straight away and create the owner account, since the first person to reach that page becomes the owner.

How do you set up email for Ghost?

Ghost sends staff invites, password resets and member sign-in links by email, so configure an authenticated SMTP relay on port 587. Outgoing port 25 should not be relied on; ask support with a ticket before planning direct delivery. Edit config.production.json in /var/www/ghost:

"mail": {
  "transport": "SMTP",
  "from": "Example Blog <noreply@example.net>",
  "options": {
    "host": "smtp.example.net",
    "port": 587,
    "secure": false,
    "auth": { "user": "noreply@example.net", "pass": "smtp-password" }
  }
}

Restart with ghost restart and send yourself a staff invite to test. Bulk newsletter delivery is a separate setting in Ghost that uses a supported bulk email service; plain SMTP covers transactional mail only. Set up SPF and DKIM for the sending domain with the SPF, DKIM and DMARC guide.

How do you check that Ghost is healthy?

Ghost-CLI has built-in commands for status, logs and diagnosis. Run them from the install directory as your normal user.

cd /var/www/ghost
ghost ls
ghost status
ghost log -n 50
ghost doctor
curl -I https://blog.example.net
systemctl status 'ghost_blog-example-net' --no-pager

ghost doctor checks permissions, Node version and the systemd unit, and suggests fixes. The site should answer with HTTP 200 and a valid certificate. Ghost itself listens on 127.0.0.1:2368 behind Nginx, which you can confirm with ss -tlnp | grep 2368.

How do you update Ghost and Node.js?

Update Ghost-CLI first, then Ghost; the CLI keeps the previous version so you can roll back.

sudo npm install -g ghost-cli@latest
cd /var/www/ghost
ghost backup
ghost update
# if something breaks:
ghost update --rollback

Before a Node.js major upgrade, check that your Ghost version lists the new Node line as supported. Then change NODE_MAJOR in the NodeSource source file, run sudo apt update && sudo apt install nodejs, and restart Ghost. Major Ghost releases sometimes raise the minimum Node and MySQL versions, so read the release notes first. See also the Node.js upgrade guide.

How do you back up a Ghost site?

Back up three things: the MySQL database, the content folder (images, themes, settings files) and config.production.json.

sudo mysqldump --single-transaction ghost_prod | gzip > ~/ghost-db-$(date +%F).sql.gz
tar -czf ~/ghost-content-$(date +%F).tar.gz -C /var/www/ghost content config.production.json

ghost backup also produces a zip with a content export, members and themes, which is handy before updates. Copy the results off the server with rsync or restic. The optional daily backups add-on protects the whole server alongside these copies, with restores handled by ticket.

Plans that fit this guide

Base city prices. Every plan includes a dedicated IPv4 address, IPv6, full root and all 18 images.

All prices
PlanFits becauseSizeMonthlyOrder from
A1-2a personal blog with swap1 vCPU, 2 GB RAM, 50 GB NVMe$7.20/mo$43.20 for 6 months
A2-4a members site with newsletters2 vCPU, 4 GB RAM, 100 GB NVMe$14.40/mo$43.20 for 3 months

Questions about Ghost publishing platform

Can I run Ghost on Debian or Rocky Linux?

Ghost-CLI officially supports Ubuntu only. It can be made to work elsewhere, or you can run the official Ghost container with Docker, but the Ubuntu path is the one the installer checks and supports.

Why can I not install Ghost as root?

Ghost-CLI refuses to run as root for safety. Use a sudo user (not named ghost); the CLI calls sudo itself when it needs to.

Can I use MariaDB instead of MySQL 8?

Not for production. Ghost supports MySQL 8 only, and some features rely on MySQL behaviour that MariaDB does not match.

How do I host two Ghost blogs on one server?

Run ghost install in a second empty directory with a different URL. Ghost-CLI picks a new local port and adds a separate Nginx block and systemd unit.

Do members need email to sign in?

Yes. Ghost uses magic links sent by email, so working SMTP is required before you open memberships.