
Deploy WordPress + MariaDB + phpMyAdmin (Protected)
WordPress MariaDB and a password-protected phpMyAdmin gateway on Railway.
phpMyAdmin Gateway
Just deployed
phpMyAdmin
Just deployed
MariaDB
Just deployed
/var/lib/mysql
WordPress
Just deployed
/var/www/html
Deploy and Host WordPress + MariaDB + Protected phpMyAdmin on Railway
WordPress is the world’s most popular open-source CMS for building websites, blogs, business sites, landing pages, and content-driven applications. This template deploys WordPress with MariaDB for persistent storage and phpMyAdmin for database management, while protecting phpMyAdmin behind a dedicated Basic Auth gateway for a safer hosted setup.
About Hosting WordPress + MariaDB + Protected phpMyAdmin
Hosting this stack on Railway means running four connected services: WordPress for the public website, MariaDB for persistent database storage, phpMyAdmin for internal database administration, and a protected gateway service for secure browser access to phpMyAdmin. This template is designed to keep WordPress public, keep MariaDB private, keep phpMyAdmin internal, and expose phpMyAdmin only through a password-protected gateway. It also includes the startup adjustments needed to avoid Apache MPM conflicts that can happen with WordPress and phpMyAdmin containers on Railway.
Common Use Cases
- Launching a WordPress blog, company site, landing page, or content website
- Running a managed WordPress stack with private MariaDB access
- Managing the WordPress database safely through protected phpMyAdmin access
Dependencies for WordPress + MariaDB + Protected phpMyAdmin Hosting
- MariaDB database
- phpMyAdmin
- Basic Auth gateway service
- Railway persistent volumes
Deployment Dependencies
- WordPress official image: https://hub.docker.com/_/wordpress
- MariaDB official image: https://hub.docker.com/_/mariadb
- phpMyAdmin official image: https://hub.docker.com/_/phpmyadmin
- Railway templates docs: https://docs.railway.com/templates
- phpMyAdmin Gateway repo: https://github.com/omryatia/caddy-phpmyadmin-gateway
- phpMyAdmin Railway wrapper repo: https://github.com/omryatia/phpmyadmin-railway
Implementation Details
This template uses four services:
- WordPress
- MariaDB
- phpMyAdmin
- phpMyAdmin Gateway
Recommended service setup:
WordPress
Image:
wordpress:php8.3-apache
Volume:
/var/www/html
Public HTTP port:
80
Environment variables:
WORDPRESS_DB_HOST=${{MariaDB.RAILWAY_PRIVATE_DOMAIN}}:3306
WORDPRESS_DB_NAME=${{MariaDB.MARIADB_DATABASE}}
WORDPRESS_DB_USER=${{MariaDB.MARIADB_USER}}
WORDPRESS_DB_PASSWORD=${{MariaDB.MARIADB_PASSWORD}}
Recommended Custom Start Command:
bash -c "grep -q 'ServerName localhost' /etc/apache2/apache2.conf || echo 'ServerName localhost' >> /etc/apache2/apache2.conf; a2dismod mpm_event || true; a2dismod mpm_worker || true; a2enmod mpm_prefork; exec docker-entrypoint.sh apache2-foreground"
Optional recommended salts and keys:
WORDPRESS_AUTH_KEY=${{ secret(64) }}
WORDPRESS_AUTH_SALT=${{ secret(64) }}
WORDPRESS_LOGGED_IN_KEY=${{ secret(128) }}
WORDPRESS_LOGGED_IN_SALT=${{ secret(128) }}
WORDPRESS_NONCE_KEY=${{ secret(128) }}
WORDPRESS_NONCE_SALT=${{ secret(128) }}
WORDPRESS_SECURE_AUTH_KEY=${{ secret(128) }}
WORDPRESS_SECURE_AUTH_SALT=${{ secret(128) }}
Optional URL configuration:
WORDPRESS_CONFIG_EXTRA=define('DOMAIN_CURRENT_SITE', '${{RAILWAY_PUBLIC_DOMAIN}}');define('WP_HOME','https://${{RAILWAY_PUBLIC_DOMAIN}}');define('WP_SITEURL','https://${{RAILWAY_PUBLIC_DOMAIN}}');
MariaDB
Image:
mariadb:lts
Volume:
/var/lib/mysql
Environment variables:
MARIADB_DATABASE=${{ secret(8, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") }}
MARIADB_USER=${{ secret(8, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") }}
MARIADB_PASSWORD=${{ secret(16) }}
MARIADB_ROOT_PASSWORD=${{ secret(24) }}
phpMyAdmin
Source repo:
https://github.com/omryatia/phpmyadmin-railway
Private only.
Environment variables:
PMA_HOST=${{MariaDB.RAILWAY_PRIVATE_DOMAIN}}
PMA_PORT=3306
This custom wrapper is used to solve Apache MPM conflicts that can appear on Railway when using phpMyAdmin directly.
phpMyAdmin Gateway
Source repo:
https://github.com/omryatia/caddy-phpmyadmin-gateway
Public HTTP port:
80
Environment variables:
PMA_UPSTREAM=${{phpMyAdmin.RAILWAY_PRIVATE_DOMAIN}}
BASIC_AUTH_USER=${{ secret(8, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") }}
BASIC_AUTH_PASSWORD=${{ secret(8, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") }}
This keeps phpMyAdmin internal while exposing access safely through the gateway.
Architecture
This template is designed with the following service visibility:
- WordPress: public
- MariaDB: private
- phpMyAdmin: private
- phpMyAdmin Gateway: public
Connection flow:
- WordPress connects to MariaDB through Railway private networking
- phpMyAdmin connects to MariaDB through Railway private networking
- phpMyAdmin Gateway connects privately to phpMyAdmin
- users access phpMyAdmin only through the public gateway
Why Deploy WordPress + MariaDB + Protected phpMyAdmin 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 + MariaDB + Protected phpMyAdmin on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your website, database, admin tools, and more on Railway.
Notes
- MariaDB should remain private and should not be exposed publicly.
- phpMyAdmin should remain internal and should only be reached through the gateway.
- WordPress stores uploads, themes, and plugins in its mounted volume.
- MariaDB stores all database data in its mounted volume.
- The phpMyAdmin wrapper and gateway repositories are maintained separately and are part of this template architecture.
Maintainer Components
Custom repositories used in this template:
- phpMyAdmin Gateway: https://github.com/omryatia/caddy-phpmyadmin-gateway
- phpMyAdmin Railway wrapper: https://github.com/omryatia/phpmyadmin-railway
Template Content
phpMyAdmin Gateway
omryatia/caddy-phpmyadmin-gatewayphpMyAdmin
omryatia/phpmyadmin-railwayMariaDB
mariadb:ltsWordPress
wordpress