Railway

Deploy Ghost CMS with MySQL | One-Click Deploy

Self Host Ghost CMS + MySQL + SMTP — publishing platform on Railway

Deploy Ghost CMS with MySQL | One-Click Deploy

Ghost

Just deployed

/var/lib/mysql

Just deployed

/var/lib/ghost/content

Deploy and Host Ghost

Deploy a self-hosted Ghost CMS instance on Railway in minutes. This template provisions Ghost (ghost:alpine) backed by a managed MySQL database, with all service wiring handled automatically — no manual config files, no server setup. Ghost railway arch

About Hosting Ghost

Ghost is an open-source, Node.js-based publishing platform built for professional content creators. Unlike bloated CMS platforms, Ghost ships with a focused editor, native membership/subscription support, and a built-in email newsletter engine.

Key features:

  • Markdown-first editor with card-based content blocks
  • Native memberships, subscriptions, and paid tiers
  • Built-in email newsletters with post-send link editing
  • ActivityPub / Social Web support (Ghost 6.0+)
  • RESTful Content and Admin APIs for headless use cases
  • Cookie-free, first-party analytics (Ghost 6.0+)

Architecture: This template runs two services — ghost:alpine and a MySQL 8 database. Ghost connects to MySQL over Railway's private network, keeping database traffic off the public internet.

Why Deploy Ghost

Managing Ghost on a VPS means provisioning NGINX, configuring SSL, installing Node.js, setting up MySQL, and writing systemd units. Railway eliminates all of that:

  • Private networking — Ghost talks to MySQL over Railway's internal network, never exposed publicly
  • Automatic environment wiring — database credentials are injected at deploy time via Railway's variable references
  • One-click deploys — no CLI, no SSH, no server management
  • Persistent volumes — your content data survives redeploys
  • Managed infrastructure — no patching, no uptime monitoring to configure

Common Use Cases

  • Independent newsletters — combine Ghost's email engine with membership tiers to run a paid newsletter without Substack's revenue cut
  • Online publications and magazines — manage high-volume article workflows with Ghost's editorial interface and role-based access
  • Developer blogs and documentation sites — use Ghost as a headless CMS, pulling content via the Content API into any frontend
  • Membership and course sites — gate premium content behind paid tiers with Ghost's native subscription tooling

Dependencies for Ghost

  • MySQL — Ghost requires MySQL 8 in production (SQLite is development-only). This template includes it.
  • SMTP provider (optional) — required for member sign-ups, magic link logins, and newsletter delivery. Mailgun, Postmark, or any SMTP service works.

Environment Variables Reference

VariableDescriptionRequired
database__clientDatabase engine (mysql)Yes
database__connection__hostMySQL hostname (private network)Yes
database__connection__databaseMySQL database nameYes
database__connection__userMySQL usernameYes
database__connection__passwordMySQL passwordYes
database__connection__portMySQL port (3306)Yes
urlPublic URL of your Ghost siteYes
PORTGhost HTTP port (2368)Yes
mail__transportEmail transport method (SMTP)Yes
mail__fromSender address for outbound emailoptional
mail__options__hostSMTP server hostnameoptional
mail__options__portSMTP server portoptional
mail__options__auth__userSMTP usernameoptional
mail__options__auth__passSMTP passwordoptional

Deployment Dependencies

Minimum Server Requirements for Ghost

ResourceMinimumRecommended
RAM512 MB1–2 GB
CPU1 vCPU2 vCPU
Disk1 GB5 GB+

Ghost's Node.js process is lightweight, but MySQL adds ~200–400 MB RAM overhead. A 1 GB instance handles small-to-medium publications comfortably.

Ghost vs WordPress

The most common migration path to Ghost is from WordPress. WordPress offers a vast plugin ecosystem but carries significant performance overhead and security surface area. Ghost is ~10× faster out of the box (Node.js vs PHP), has zero plugin dependencies for core publishing workflows, and includes memberships and newsletters natively — no WooCommerce, no Mailchimp plugin required. If you publish content and monetize an audience, Ghost's focused scope is an advantage, not a limitation.

Ghost vs Substack

Substack is fully managed but takes a 10% cut of subscription revenue and owns your audience relationship. Self-hosted Ghost on Railway gives you full data ownership, custom domain, and zero revenue share. The trade-off is infrastructure responsibility — which this template minimises significantly.

Getting Started with Ghost

After Railway deploys your template, navigate to https://your-domain.railway.app/ghost to access the admin setup wizard. Create your administrator account, set your publication name, and configure your theme. To enable member sign-ups and newsletters, add your SMTP credentials to the Ghost service's environment variables in the Railway dashboard and redeploy. Your first post can be published immediately — Ghost's editor is live at /ghost/#/editor.

Ghost setup page

Self-Hosting Ghost with Docker

To run Ghost outside Railway on any Linux VPS:

docker run -d \
  --name ghost \
  -e NODE_ENV=production \
  -e url=https://yourdomain.com \
  -e database__client=mysql \
  -e database__connection__host=your-mysql-host \
  -e database__connection__user=root \
  -e database__connection__password=yourpassword \
  -e database__connection__database=ghost \
  -p 2368:2368 \
  ghost:alpine

For production, pair this with a MySQL 8 container and an NGINX reverse proxy handling SSL termination. The official Ghost Docker tooling repository at github.com/TryGhost/Ghost includes a Docker Compose setup with Caddy for automated HTTPS.

How Much Does Ghost Cost?

Ghost is fully open-source (MIT licence) — the software itself is free. Hosting cost is purely infrastructure. On Railway, you pay for compute and memory used. Ghost(Pro), the managed cloud offering from the Ghost Foundation, starts at $9/month for personal use and scales to $199/month for large publications. Self-hosting on Railway typically costs a fraction of Ghost(Pro) pricing while giving you equivalent control.

Troubleshooting

Ghost fails to start: Check that all database__connection__* variables are correctly set and that the MySQL service is healthy before Ghost attempts to connect. Railway's service dependency ordering helps, but a brief startup delay is normal.

Emails not sending: Confirm mail__options__host, mail__options__port, and SMTP credentials are set. Test with a transactional email provider like Mailgun on port 587 with STARTTLS.

Ghost 6.0 MySQL migration error: If you see an ANSI_QUOTES SQL syntax error during upgrade, ensure ANSI_QUOTES mode is disabled in your MySQL configuration before running the migration.

FAQ

Is Ghost good for blogs and online magazines? Yes. Ghost is purpose-built for content-driven sites. It supports rich media, SEO metadata, custom themes, and high-volume article management. A standout feature is the ability to edit links in already-delivered email newsletters — useful when a URL changes after sending.

Does Ghost support memberships and monetisation? Ghost has native membership and subscription support built in. You can offer free and paid tiers, gate content, and collect recurring payments via Stripe — no third-party plugins needed.

What database does Ghost use in production? MySQL 8. SQLite is supported for local development only. This template provisions MySQL automatically.

Can I use Ghost as a headless CMS? Yes. Ghost exposes a Content API and Admin API, making it straightforward to use as a headless backend with any frontend framework.


Template Content

More templates in this category

View Template
Strapi
A popular self-hosted CMS

Milo
7.5K
Deploy
View Template
WordPress with Redis
Deploy WordPress with MariaDB and Redis

Noor Adn
View Template
Directus (docker/websocket/extensions) + PostGIS (docker/TCP) + S3/Local
Directus (Docker) + PostGIS (Docker/TCP) + S3

Protemplate