---
title: "Deploy WordPress | High Performance Self-Hosted CMS Server"
description: "One-click self-host WordPress with MariaDB | Blogs, stores, and portfolios"
category: "CMS"
url: https://railway.com/deploy/deploy-wordpress
---

# Deploy WordPress | High Performance Self-Hosted CMS Server

One-click self-host WordPress with MariaDB | Blogs, stores, and portfolios

**[Deploy WordPress | High Performance Self-Hosted CMS Server on Railway](https://railway.com/template/deploy-wordpress)**

- **Creator:** Heimdall
- **Category:** CMS
- **Total deploys:** 104

## Template content

### mariadb https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons/svg/mariadb.svg

- **Image:** mariadb:latest

### WordPress https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons/svg/wordpress.svg

- **Image:** wordpress
- **Start command:** `/bin/sh -c 'set -eu; a2dismod mpm_event mpm_worker || true; a2enmod mpm_prefork || true; exec docker-entrypoint.sh "$@"' -- apache2-foreground`
- **Public domain:** Yes

## Documentation

![WordPress logo](https://cmscritic.com/ms-content/uploads/2023/08/wplogoblue-stacked-rgb_zqpuyr.png?format=auto&width=2048)

# Deploy and Host WordPress on Railway

Deploy a fully self-hosted WordPress instance on Railway in one click — complete with a MariaDB database, persistent volumes, and auto-generated security keys. No manual server setup, no LAMP stack configuration, no SSL wrangling.

## About Hosting WordPress

WordPress is the world's most popular open-source CMS, powering over 40% of all websites. This Railway template runs the official `wordpress` Docker image alongside `mariadb` (the `mariadb` Docker image), connected over Railway's private network with persistent storage for both the web root and database.

**What you get:**
- WordPress on Apache (MPM Prefork, optimised for PHP compatibility)
- MariaDB with auto-generated credentials
- Persistent volumes: `/var/www/html` (WordPress files) and `/var/lib/mysql` (database)
- All 8 WordPress security salts and keys pre-generated
- `WP_HOME` and `WP_SITEURL` wired to your Railway public domain automatically

## Why Deploy WordPress on Railway

Managing WordPress on a VPS means configuring Apache/Nginx, PHP, MariaDB, SSL, and keeping everything patched. Railway eliminates that entirely:

- **Private networking** — WordPress talks to MariaDB over Railway's internal network, never the public internet
- **Persistent volumes** — uploads and database survive redeploys
- **Environment variable UI** — rotate secrets or change DB credentials without SSH
- **One-click deploy** — the entire two-container stack is ready in under two minutes
- **No cold-start complexity** — unlike static exports (Cloudflare Pages + Simply Static), this runs full dynamic WordPress with `/wp-admin`, plugins, and WooCommerce

## Common Use Cases

- **Business blogs and content sites** — editorial teams that need the full plugin ecosystem (SEO, forms, analytics)
- **WooCommerce stores** — product catalogues, payment gateways (Stripe, PayPal), inventory management
- **Membership and subscription sites** — gated content with plugins like MemberPress or Paid Memberships Pro
- **Digital product stores** — sell e-books, courses, or software with Easy Digital Downloads and automated delivery

## Dependencies for WordPress

- A Railway account (free tier works for low-traffic sites)
- A custom domain (optional but recommended — Railway provides a public domain by default)

### Environment Variables Reference

| Variable | Description | Required |
|---|---|---|
| `WORDPRESS_DB_HOST` | MariaDB host:port (auto-wired from mariadb service) | ✅ |
| `WORDPRESS_DB_NAME` | Database name (`railway`) | ✅ |
| `WORDPRESS_DB_USER` | Database user (`railway`) | ✅ |
| `WORDPRESS_DB_PASSWORD` | Auto-generated 32-char password | ✅ |
| `WORDPRESS_CONFIG_EXTRA` | Sets `WP_HOME`, `WP_SITEURL`, `DOMAIN_CURRENT_SITE` | ✅ |
| `WORDPRESS_AUTH_KEY` / `WORDPRESS_AUTH_SALT` | Security keys (auto-generated) | ✅ |
| `MARIADB_ROOT_PASSWORD` | MariaDB root password (auto-generated) | ✅ |
| `MARIADB_PUBLIC_URL` | External connection string for DB tools | Optional |
| `PORT` | WordPress container port (`80`) | ✅ |

### Deployment Dependencies

- Docker image: [`wordpress`](https://hub.docker.com/_/wordpress) (official)
- Docker image: [`mariadb`](https://hub.docker.com/_/mariadb) (official)
- Apache MPM Prefork (enforced via custom start command for PHP compatibility)

## Self-Hosting WordPress with Docker

To run this same stack on your own VPS:

```
# docker-compose.yml
services:
  wordpress:
    image: wordpress
    ports:
      - "80:80"
    environment:
      WORDPRESS_DB_HOST: mariadb:3306
      WORDPRESS_DB_NAME: wordpress
      WORDPRESS_DB_USER: wpuser
      WORDPRESS_DB_PASSWORD: strongpassword
    volumes:
      - wordpress_data:/var/www/html
    command: >
      /bin/sh -c 'a2dismod mpm_event mpm_worker || true;
      a2enmod mpm_prefork || true;
      exec docker-entrypoint.sh apache2-foreground'

  mariadb:
    image: mariadb
    environment:
      MARIADB_DATABASE: wordpress
      MARIADB_USER: wpuser
      MARIADB_PASSWORD: strongpassword
      MARIADB_ROOT_PASSWORD: rootpassword
    volumes:
      - mariadb_data:/var/lib/mysql

volumes:
  wordpress_data:
  mariadb_data:
```

```
docker compose up -d
# WordPress available at http://localhost
```

Railway handles the networking, secrets, and domain automatically — the above is what you'd manage yourself on a VPS.

## WordPress vs WordPress.com

| | Self-hosted (this template) | WordPress.com |
|---|---|---|
| Plugin freedom | Any plugin | Paid plans only |
| WooCommerce | Full support | Commerce plan required |
| Cost | Infrastructure only | $4–$45/month |
| Control | Complete | Platform-limited |
| Maintenance | Railway manages infra | Fully managed |

Self-hosted WordPress on Railway gives you `.org` freedom at close to `.com` convenience.

## Getting Started with WordPress on Railway

After deployment, click the generated Railway public URL — you'll land on the WordPress 5-minute install wizard. Choose your site title, create an admin username and strong password, and enter your email. Once complete, log in at `/wp-admin` and install your first theme or plugin. Your uploads and database are persisted to volumes, so nothing is lost on redeploy.

![WordPress dashboard screenshot](https://upload.wikimedia.org/wikipedia/commons/2/23/WordPress_6.4_Dashboard.png)

## How Much Does WordPress Cost?

WordPress itself is free and open-source (GPL licensed) — there are no licensing fees. On Railway, you pay only for the infrastructure you consume (compute + volume storage). The Railway Hobby plan starts at $5/month with usage-based billing on top. Plugins and themes range from free to several hundred dollars for premium licences, but the core CMS costs nothing.

## Troubleshooting

**White screen / 500 error on first load** — the MPM Prefork module may not have loaded. Check Railway logs; the custom start command explicitly enables it.

**"Error establishing a database connection"** — confirm `WORDPRESS_DB_HOST` matches `mariadb.MARIADB_HOST:mariadb.MARIADB_PORT`. Railway's private networking requires both services to be in the same project.

**Uploads not persisting** — ensure the `/var/www/html` volume is attached to the WordPress service in Railway's volume settings.

## FAQ

**Does this start WordPress and a database in separate containers?**
Yes. The template deploys two services: `wordpress` (Apache + PHP) and `mariadb`, each in its own container. They communicate over Railway's private network using the internal `MARIADB_HOST` variable — the database port is never exposed publicly unless you explicitly enable TCP proxy.

**Can I use WordPress for e-commerce, memberships, and digital products?**
Absolutely. WordPress with WooCommerce is one of the most common e-commerce stacks on the web. The same installation supports membership plugins (MemberPress, Restrict Content Pro), digital downloads (Easy Digital Downloads), and subscription billing — all installable directly from `/wp-admin` after deployment.

**Will my data survive a redeploy?**
Yes. Both services have persistent volumes attached (`/var/www/html` for WordPress files and `/var/lib/mysql` for MariaDB), so themes, plugins, uploads, and database records are preserved across redeploys.

**Can I connect an external database tool to MariaDB?**
Yes. Use `MARIADB_PUBLIC_URL` with a client like TablePlus or DBeaver. The TCP proxy domain and port are exposed via `MARIADB_PUBLIC_HOST` and `MARIADB_PUBLIC_PORT`.


## Similar templates

- [Libredesk - Complete Setup](https://railway.com/deploy/libredesk-complete-setup) — [Jul'26] Complete self-hosted omnichannel customer support desk.
- [Instatic CMS - Postgres](https://railway.com/deploy/instatic-cms-postgres) — Design, build and manage powerful static sites from state-of-the-art CMS
- [Strapi](https://railway.com/deploy/strapi) — A popular self-hosted CMS

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