How to Self-Host Ghost

Ghost is open-source publishing software with built-in memberships and newsletters, and you can run it yourself on almost any Linux server. This guide walks through the hand-built route with Docker Compose, shows the parts that usually go wrong, and then describes what changes if you use a prepared server instead.

What you are taking on

Ghost itself is one Node application. The work is everything around it. You need a database, a place to keep uploaded images and themes, HTTPS, working email, a backup routine and a way to apply updates. Ghost is released roughly weekly, so the update question comes back often. None of this is difficult, but it is a steady amount of small maintenance, and it is worth deciding up front whether you want it.

Ghost's stated requirements are Node 22, MySQL 8 and at least 1 GB of RAM. The full breakdown is in the Ghost server requirements guide. Two rules shape every setup: MySQL 8 is the only supported database in production, and there must be exactly one Ghost instance per site, because clustering is not supported.

Option 1: Docker Compose by hand

Step 1: Get a server

Any Linux server with Docker and Docker Compose will do. A virtual server with 1 GB of RAM meets Ghost's minimum for Ghost alone, but the database runs on the same machine, so leave yourself headroom. Check that your provider does not block outbound SMTP ports, because some do, and you will need them later for email.

Step 2: Write the Compose file

The official ghost image is published by the Ghost Foundation. It exposes port 2368, keeps its data in /var/lib/ghost/content, and reads any Ghost option from environment variables, using a double underscore for nesting. A minimal file looks like this:

services:
  ghost:
    image: ghost:6-alpine
    restart: always
    ports:
      - "127.0.0.1:2368:2368"
    environment:
      url: https://blog.example.com
      database__client: mysql
      database__connection__host: db
      database__connection__user: root
      database__connection__password: change-this-password
      database__connection__database: ghost
    volumes:
      - ghost-content:/var/lib/ghost/content
    depends_on:
      - db
  db:
    image: mysql:8
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: change-this-password
    volumes:
      - ghost-db:/var/lib/mysql
volumes:
  ghost-content:
  ghost-db:

Three details matter. First, url must be the real public address, including https://. A wrong value produces an "access denied from url" error in the admin. Second, both volumes must be persistent, or a recreated container starts empty. Third, restart: always is doing real work: if Ghost starts before MySQL accepts connections, Ghost exits on its first refused query, and the restart policy brings it back once the database is up.

Step 3: Put a reverse proxy in front

The compose file publishes Ghost only on the loopback interface. A reverse proxy such as NGINX or Caddy listens on ports 80 and 443, obtains a certificate, and forwards requests to port 2368. The one setting people miss is the forwarded protocol header:

location / {
    proxy_pass http://127.0.0.1:2368;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
}

Without X-Forwarded-Proto, Ghost believes every request arrived over plain HTTP, compares that with the https in its url, and answers with a redirect to https. The browser follows it, arrives through the same proxy, and the cycle repeats. If you see a redirect loop, check this header before anything else.

Step 4: Create the owner account quickly

Start the stack with docker compose up -d, wait for the first boot, which runs the database migrations, and open /ghost on your domain. Until the first owner exists, the setup screen is open to anyone who reaches it, so create the owner account right away rather than leaving a fresh site exposed.

Step 5: Add email

Ghost needs outbound email for member sign-in links, staff invitations and password resets. Add the SMTP settings to the same environment block:

  • mail__transport: SMTP
  • mail__from, the sender address
  • mail__options__host, mail__options__port and mail__options__secure
  • mail__options__auth__user and mail__options__auth__pass

Newsletters are a separate matter and need Mailgun. The full picture, including DNS records, is in the Ghost email setup guide.

Step 6: Back up the right things

A complete Ghost backup has two parts that belong together: a dump of the MySQL database and a copy of the content folder, which holds images, media, themes and files. The JSON export in Ghost Admin is useful for moving content, but it does not include comments, member activity history or your media files, so it is not a backup on its own. Store copies somewhere other than the server, and test a restore at least once.

Step 7: Update by replacing the image

Ghost cannot update itself inside a container. An update is a new image: change the tag or pull the current one, run docker compose up -d, and Ghost applies its migrations at the next start. Before a major version, make sure you are on the latest minor version of the current major. Take a backup first, every time.

Option 2: A prepared server

The alternative is to start from an image and a server where the plumbing above is already done. Hosting for Ghost on Flux runs the runonflux/ghost-flux image, which uses the official Ghost Alpine image underneath, together with MySQL 8.3, on the Flux decentralized cloud. It is built so you do not have to solve the first four problems in this guide:

  • An nginx layer in front of Ghost sets the forwarded protocol header correctly, so there is no redirect loop.
  • The site address defaults to a free .app.runonflux.io address with HTTPS, and you change it by adding your own domain.
  • Ghost waits for the database before it starts instead of exiting on the first refused connection.
  • Passwords in the app specification are encrypted, so they are not readable on the network.

The panel provides Overview, Location, Hardware, Console, Files, Backup, Deployment Settings, Domain, Renew and Support. The Ghost tools include a version and health view, database export and import, content backup and restore, password reset for staff, a setting for who may sign up, and an update check. Backups are taken on demand, so you still decide when to take one. New Ghost releases are followed and tested before the image is published.

What the two routes compare like

TaskDocker Compose by handPrepared server
Server and DockerYou provision and patch itProvided on the Flux decentralized cloud
Proxy and HTTPSYou configure NGINX or Caddy and certificatesHTTPS on a free address, custom domain by CNAME
DatabaseYou run and secure MySQL 8Included with the plan
EmailYou add SMTP and MailgunYou add SMTP and Mailgun; neither is included
BackupsYour own scriptsTaken on demand from the panel
UpdatesYou pull and recreateTested before publishing, then installed for you
Control of the hostFull, including the OSContainer and its settings only

How to choose

Choose the hand-built route if you already run servers, want full control of the machine, or want Ghost next to other services you manage. Choose a prepared server if you would rather spend your time writing than maintaining a proxy and a backup script. Neither route changes Ghost itself: it is the same MIT-licensed software, and your content moves between them with an export and a content folder copy. The cost side is covered in what running a Ghost site costs, and the section home lists the plans.

See the plans for Hosting for Ghost on Flux, or compare costs in the cost guide.

Frequently Asked Questions

Can I run Ghost without Docker?

Yes. Ghost supports a direct install with Node 22, MySQL 8 and NGINX on a supported Ubuntu release, using Ghost’s own command line tool. Docker is a choice, not a requirement. This guide uses Docker because an image can be replaced as a whole, which makes updates and rollbacks simpler to reason about.

Why does Ghost redirect to https in a loop behind my proxy?

Ghost compares the protocol of each request with the protocol in its url setting. If your proxy terminates HTTPS and does not send an X-Forwarded-Proto header, Ghost sees plain HTTP, tries to redirect to https, and the redirect never ends. Set the header in the proxy and the loop stops.

Can I use SQLite instead of MySQL?

Not in production. Ghost documents MySQL 8 as the only supported production database; SQLite is for local development. If you are coming from MariaDB, plan a migration to MySQL 8.

Can I run two Ghost containers for more capacity?

No. Ghost supports one instance per site and does not support clustering. Capacity comes from a bigger server and from caching in front of the site, not from running copies. The three copies of your app on Flux are for failover: only one Ghost serves readers at a time and the others stand by.

How do I update Ghost in Docker?

Pull the new image tag and recreate the container. Take a database dump and a copy of the content folder first, and move through major versions only after you are on the latest minor version of the current one. Ghost runs its database migrations at the next start.

What does a prepared server change about this?

It replaces steps you would otherwise do yourself: the proxy header, the url default, waiting for the database, and a panel for backups and updates. You still choose and configure email. Hosting for Ghost on Flux is described on the section home page.

Ghost is a trademark of Ghost Foundation (https://ghost.org). Flux is not affiliated with or endorsed by Ghost Foundation.

Hosting for Ghost on the decentralized cloud

Dedicated resources, a synced MySQL database, HTTPS and your own domain. From $6.99/month.

Hosting for Ghost on Flux

Publish. Email. Earn. On your own site.

A product of Flux

Ghost is a trademark of Ghost Foundation (https://ghost.org). Flux is not affiliated with or endorsed by Ghost Foundation.

© 2026 InFlux Technologies. All rights reserved. v1.20.0