---
title: "Deploy Ghost on Railway"
description: "In this post, we go over the process of deploying and maintaining a Ghost (a free and open-source publishing platform) instance connected to a MySQL database on Railway!"
date: 2021-06-11T00:00:00.000Z
updated: 2026-10-29T11:13:17.544Z
topics: ["Guides"]
tags: []
url: https://railway.com/guides/ghost
---

# Deploy Ghost on Railway

In this post, we go over the process of deploying and maintaining a Ghost (a free and open-source publishing platform) instance connected to a MySQL database on Railway!

---

[Ghost](https://ghost.org/) is an open-source publishing platform for building and running blogs, magazines, and journals. You can choose from an array of free and paid themes from their [marketplace](https://ghost.org/marketplace/) or even build your own. Ghost also allows you to send newsletters and monetize your blog by setting up subscriptions using [Stripe](https://stripe.com/).

The company behind Ghost offers a hosted version [starting at $9/month](https://ghost.org/pricing/) but you can also self-host Ghost. At Railway, we provide a free one-click deploy for Ghost using a MySQL database which we automagically provision for you.

## Deploying with Railway

[https://railway.com/new/template/ghost](https://railway.com/new/template/ghost)

To deploy your Ghost instance on Railway, simply click the button above ([source code](https://github.com/railwayapp-starters/ghost)), enter the mentioned environment variables and hit deploy. The required MySQL database will be automagically provisioned and the required database migrations will be run for you.

The environment variables we ask you to enter are all optional but we highly recommend entering them to run a full-fledged Ghost blog.

- **CLOUDINARY_URL**: Railway's filesystem is ephemeral. Which means that any changes to the filesystem are not persisted between deploys. This is why we've set up [Cloudinary](https://cloudinary.com/) for the Ghost blog. All the media in your blog post will be stored on your Cloudinary account and served via their CDN.
- **MAILGUN_SMTP_LOGIN** and **MAILGUN_SMTP_PASSWORD**: [Mailgun](https://mailgun.com/) is the default email provider that works with Ghost. Adding these environment variables allows you to email your subscribers whenever you publish a new post and also to invite additional team members to publish posts and manage the blog.

## Changing the theme

By default, we've bundled two themes ([Casper](https://github.com/TryGhost/Casper) and [Lyra](https://github.com/TryGhost/Lyra)) with the Ghost starter. If you'd like to use a different theme (take [Pico](https://github.com/TryGhost/Pico) as an example), here are the steps you need to follow:

- First, add the theme as a dependency to the `package.json` file.

```json
{
	...
	dependencies: {
		"pico": "github:TryGhost/Pico#main"
		...
	}
}
```

- Next, add the theme name to the list of themes in the [`themes.sh` file](https://github.com/railwayapp/starters/blob/master/examples/ghost/bin/themes.sh#L1).

```bash
themes=(
	casper
	lyra
	pico
)
...
```

- Push your changes to Github and your project should be redeployed automatically.

<aside>
💡 Do not add a theme directly using the Ghost UI. While it will appear to work initially, the install will not persist due to Railway's ephemeral filesystem.

</aside>

![Homepage of a Ghost blog deployed on Railway](https://cms.railway.com/media/b1ce5423c0d866c1c196cc5d9ab4ec0f2f47ee61580df7487df9060386ad2fb4.png)

## Closing

And with that you should have all the information you need to set up your blog on Railway using Ghost. You should be able to write and publish posts, invite teammates, set up a newsletter and subscriptions. You can even attach a [custom domain](https://docs.railway.com/networking/public-networking) to your Ghost instance.

If you have any suggestions for more open-source self-hosted solutions you'd like to see guides for, let us know on [Discord](https://discord.com/invite/xAm2w6g). Or even better, submit a pull request to our [starters repository](https://github.com/railwayapp/starters) on Github!