Railway

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

WordPress with Database

Just deployed

/var/lib/mysql

WordPress

wordpress

Just deployed

/var/www/html

WordPress logo

Deploy and Host deploy-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 deploy-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

VariableDescriptionRequired
WORDPRESS_DB_HOSTMariaDB host:port (auto-wired from mariadb service)
WORDPRESS_DB_NAMEDatabase name (railway)
WORDPRESS_DB_USERDatabase user (railway)
WORDPRESS_DB_PASSWORDAuto-generated 32-char password
WORDPRESS_CONFIG_EXTRASets WP_HOME, WP_SITEURL, DOMAIN_CURRENT_SITE
WORDPRESS_AUTH_KEY / WORDPRESS_AUTH_SALTSecurity keys (auto-generated)
MARIADB_ROOT_PASSWORDMariaDB root password (auto-generated)
MARIADB_PUBLIC_URLExternal connection string for DB toolsOptional
PORTWordPress container port (80)

Deployment Dependencies

  • Docker image: wordpress (official)
  • Docker image: 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 freedomAny pluginPaid plans only
WooCommerceFull supportCommerce plan required
CostInfrastructure only$4–$45/month
ControlCompletePlatform-limited
MaintenanceRailway manages infraFully 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

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.


Template Content

WordPress

wordpress

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