---
title: "Deploy Wordpress"
description: "Self-hosted WordPress with MariaDB, HTTPS and a persistent volume."
category: "CMS"
url: https://railway.com/deploy/wordpress-mariadb
---

# Deploy Wordpress

Self-hosted WordPress with MariaDB, HTTPS and a persistent volume.

**[Deploy Wordpress on Railway](https://railway.com/template/wordpress-mariadb)**

Machine-readable deploy manifest (JSON, validated by TemplateCI): https://railway.com/deploy/wordpress-mariadb/manifest.json

- **Creator:** blueorange
- **Category:** CMS

## Template content

### MariaDB https://img.icons8.com/color/48/maria-db.png

- **Image:** mariadb

### Primary https://img.icons8.com/color/48/000000/wordpress.png

- **Image:** wordpress
- **Start command:** `/bin/bash -c "echo 'ServerName 0.0.0.0' >> /etc/apache2/apache2.conf && echo 'DirectoryIndex index.php index.html' >> /etc/apache2/apache2.conf && echo 'upload_max_filesize = 50M' >> /usr/local/etc/php/php.ini && echo 'post_max_size = 50M' >> /usr/local/etc/php/php.ini && docker-entrypoint.sh a2dismod mpm_event && a2dismod mpm_worker && a2enmod mpm_prefork && apache2-foreground"`
- **Public domain:** Yes

## Documentation

# Deploy and Host WordPress on Railway

![WordPress logo](https://s.w.org/style/images/about/WordPress-logotype-standard.png)

WordPress powers **39.6% of all websites** — more than every other CMS combined — with thousands of themes and plugins for blogs, business sites and stores. This template runs the official WordPress image with a MariaDB database on Railway, with HTTPS and your files on a persistent volume. Managed WordPress hosts like WP Engine start at $28/month — run your own WordPress on Railway for ~$5–10/month with full plugin and theme access.

---

## What This Template Deploys

| Service | Purpose |
|---|---|
| **Primary** | Official `wordpress` image on Apache, public HTTPS domain. Upload limit raised to 50 MB; site URL set to your Railway domain automatically. |
| **MariaDB** | MariaDB database for posts, pages, users and settings, reached over Railway's private network. |
| **Persistent Volume** | Mounted at `/var/www/html` on Primary — WordPress core, themes, plugins and media uploads survive redeploys. |
| **Persistent Volume** | Mounted at `/var/lib/mysql` on MariaDB — your database survives redeploys. |

Two services wired together through variable references: WordPress gets the database host, name, user and password from MariaDB, and all eight security keys and salts are generated at deploy time.

---

## About Hosting WordPress

A self-hosted WordPress site needs PHP and a web server, a MySQL-compatible database, storage for uploads and plugins that survives updates, HTTPS, and correct site URLs so redirects and logins work. On a VPS that's a LAMP stack, Certbot and backups to manage yourself.

On Railway, WordPress and MariaDB start together, HTTPS is automatic, `WP_HOME` and `WP_SITEURL` point at your Railway domain, and both the site files and the database live on volumes. You install any plugin or theme from the dashboard, with no host restrictions.

**Using a custom domain? Update the site URL.** `WORDPRESS_CONFIG_EXTRA` sets `WP_HOME` and `WP_SITEURL` to the Railway domain. When you add your own domain, change both to `https://yourdomain.com` and redeploy, or WordPress will keep redirecting to the old address.

Typical cost: **~$5–10/month** on Railway for a small site, including the database. WordPress.com's plugin-capable Personal plan is $4/month billed yearly ($9 monthly), WP Engine starts at $28/month and Kinsta at $30/month.

---

## Deploy WordPress in Under 5 Minutes

1. Click **Deploy on Railway** — WordPress and MariaDB start with generated passwords and keys (~2–3 minutes).
2. Open the public URL and run the WordPress installer: site title, admin user and password.
3. Sign in at `/wp-admin` and install your theme and plugins.
4. Add a caching plugin and an image-optimisation plugin for speed.
5. For a custom domain, add it in Railway and update `WP_HOME` and `WP_SITEURL` in `WORDPRESS_CONFIG_EXTRA`.

No LAMP stack. No Certbot. No plugin restrictions.

---

## Common Use Cases

- **Self-hosted WordPress hosting** — "host wordpress" with full plugin access and no visit caps
- **Business and portfolio sites** — any theme from the WordPress directory or marketplaces
- **Blogs and publications** — the editor millions of writers already know
- **WooCommerce stores** — add WooCommerce for products, carts and payments
- **Client sites for agencies** — one Railway project per client, billed by usage
- **Staging copies** — clone a site to test plugins and updates safely

---

## Configuration

| Variable | Required | Description |
|---|---|---|
| `WORDPRESS_DB_HOST`, `WORDPRESS_DB_NAME`, `WORDPRESS_DB_USER`, `WORDPRESS_DB_PASSWORD` | ✅ Auto-injected | Database connection from the MariaDB service (private network). |
| `WORDPRESS_AUTH_KEY`, `…_SALT` and the other keys | 🔐 Auto-generated | WordPress security keys and salts. Changing them logs everyone out. |
| `WORDPRESS_CONFIG_EXTRA` | ✅ Set | Sets `WP_HOME`, `WP_SITEURL` and `DOMAIN_CURRENT_SITE` to your Railway domain. Update for a custom domain. |
| `MARIADB_PASSWORD`, `MARIADB_ROOT_PASSWORD` | 🔐 Auto-generated | Database passwords. |
| `MARIADB_DATABASE`, `MARIADB_USER` | Optional | `railway` by default. |
| `PORT` | Auto-set | `80`, the port Apache listens on. |

**WordPress email needs a mail plugin.** WordPress sends password resets and notifications by email; Railway blocks outbound SMTP on the Hobby plan, so use a mail plugin that sends through an HTTPS API (such as Postmark, Mailgun or SendGrid), or SMTP on Railway Pro.

---

## WordPress on Railway vs. Alternatives

| | WordPress on Railway | WordPress.com | WP Engine | Kinsta |
|---|---|---|---|---|
| **Monthly cost** | ~$5–10 usage | $4 Personal (yearly), $9 monthly | From $28 | From $30 (annual), $35 monthly |
| **Self-hosted** | ✅ Yes | ❌ No | ❌ No | ❌ No |
| **Any plugin or theme** | ✅ Yes | ✅ From Personal | ⚠️ Some plugins disallowed | ⚠️ Some plugins disallowed |
| **Visit limits** | ✅ None, pay for usage | ✅ None stated | ❌ 25,000+ by plan | ❌ 35,000 on Single |
| **Direct database access** | ✅ Your MariaDB | ❌ No | ⚠️ phpMyAdmin | ⚠️ phpMyAdmin |
| **Managed updates and backups** | ⚠️ Your responsibility | ✅ Yes | ✅ Yes | ✅ Yes |
| **License** | ✅ GPL (WordPress) | ✅ GPL core, proprietary host | ✅ GPL core, proprietary host | ✅ GPL core, proprietary host |

---

## Dependencies for WordPress Hosting

- Railway account — Hobby ($5/month) covers a small site; Pro for busy sites or SMTP email.
- A mail delivery service (Postmark, Mailgun, SendGrid) for password resets and notifications.
- Optional: a CDN or caching plugin for high-traffic sites.

### Deployment Dependencies

- [WordPress.org](https://wordpress.org/documentation/) — documentation
- [WordPress Docker image](https://hub.docker.com/_/wordpress) — the image this template runs
- [MariaDB Docker image](https://hub.docker.com/_/mariadb) — the database image
- [Railway Volumes Documentation](https://docs.railway.com/volumes) — persistence

### Implementation Details

The Primary service runs the official `wordpress` image on Apache with the prefork MPM, raises PHP's upload and post limits to 50 MB, and serves `/var/www/html` from a volume, so core files, themes, plugins and uploads persist. WordPress reaches MariaDB on the private network through `WORDPRESS_DB_HOST`.

`WORDPRESS_CONFIG_EXTRA` injects `WP_HOME`, `WP_SITEURL` and `DOMAIN_CURRENT_SITE` into `wp-config.php` using your Railway domain. Both images track their latest tags; pin specific versions once your site is live, and keep WordPress, themes and plugins updated from the dashboard.

---

## Frequently Asked Questions

**What does this WordPress template include?**
The official WordPress image on Apache, a MariaDB database, generated security keys, HTTPS on your Railway domain, and persistent volumes for site files and the database.

**How much does it cost compared to managed WordPress hosting?**
About $5–10/month on Railway for a small site, database included, with no visit limits. WP Engine starts at $28/month, Kinsta at $30/month, and WordPress.com's Personal plan at $4/month billed yearly.

**Why does my site redirect to the Railway URL after adding a custom domain?**
`WP_HOME` and `WP_SITEURL` are set in `WORDPRESS_CONFIG_EXTRA`. Change both to your new domain (with `https://`) and redeploy.

**Do I lose posts, plugins or uploads when I redeploy?**
No. Posts and settings are in MariaDB on its own volume, and WordPress core, themes, plugins and uploads are on the `/var/www/html` volume.

**Can I install any plugin, including WooCommerce?**
Yes. It's your own WordPress install, so every plugin and theme works, including WooCommerce.

**Who handles updates and backups?**
You do. Update WordPress, themes and plugins from the dashboard, and enable Railway volume backups or a backup plugin for both the site and database.

---

## Why Deploy and Host WordPress on Railway?

Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.

By deploying WordPress on Railway, you get your own WordPress and MariaDB with HTTPS, persistent storage and full plugin freedom, for a few dollars a month and no visit limits.


## Similar templates

- [Libredesk - Complete Setup](https://railway.com/deploy/libredesk-complete-setup) — Complete self-hosted omnichannel customer support desk.
- [Paperless-ngx](https://railway.com/deploy/paperless-ngx-3) — Paperless-ngx — document management with OCR and full-text search
- [Instatic CMS - Postgres](https://railway.com/deploy/instatic-cms-postgres) — Design, build and manage powerful static sites from state-of-the-art CMS

Open this page in a browser: https://railway.com/deploy/wordpress-mariadb
