Deploying a WordPress App
Introduction
WordPress powers millions of sites and is easy to customize with plugins and themes. This guide shows how to containerize WordPress with a Dockerfile, connect it to MySQL, persist uploads, and deploy it to Klutch.sh over HTTP.
Prerequisites
- GitHub repository containing your Dockerfile.
- MySQL database (managed or deployed separately).
- Klutch.sh project ready in klutch.sh/app.
Project structure
.└── DockerfileSample Dockerfile
FROM wordpress:6.5-php8.2-apache
# Default WordPress portENV APACHE_PORT=80EXPOSE 80Required environment variables
WORDPRESS_DB_HOST– MySQL host and portWORDPRESS_DB_USERWORDPRESS_DB_PASSWORDWORDPRESS_DB_NAMEAPACHE_PORT=80
Optional environment variables
WORDPRESS_TABLE_PREFIX=wp_WORDPRESS_DEBUG=falseWP_MEMORY_LIMIT=256M
Persistence
Persist plugins, themes, and uploads:
- Mount path:
/var/www/html/wp-content - Size: based on expected media, plugins, and themes
Networking
- Protocol: HTTP
- Internal port:
80 - Users reach
https://example-app.klutch.shwhile Klutch.sh routes to port80inside the container.
Health check (recommended)
curl -I http://localhostDeployment on Klutch.sh
- Push your Dockerfile to GitHub.
- In klutch.sh/app, create a new app and select GitHub as the source.
- Klutch.sh automatically detects the Dockerfile in the repository root.
- Select HTTP traffic and set the internal port to
80. - Add environment variables for
WORDPRESS_DB_HOST,WORDPRESS_DB_USER,WORDPRESS_DB_PASSWORD, andWORDPRESS_DB_NAME. Mark secrets as sensitive. - Attach a persistent volume at
/var/www/html/wp-contentsized for uploads and custom code. - Deploy. Finish the WordPress setup wizard and start installing themes or plugins.
Verification
-
UI: open
https://example-app.klutch.shand confirm the WordPress site loads. -
Quick check:
Terminal window curl -I https://example-app.klutch.sh
Next steps
- Configure HTTPS at the edge and set your site URL in WordPress settings.
- Enable backups for MySQL and the
/var/www/html/wp-contentvolume. - Add caching and security plugins to harden your site.