Skip to content

Deploying a WordPress App

Introduction

WordPress is the world’s most popular open-source content management system (CMS), powering millions of websites and blogs. It is built with PHP and MySQL, offering a user-friendly interface for publishing, managing, and customizing content. This guide explains how to deploy a WordPress application on Klutch.sh using a Dockerfile for maximum flexibility and control.


Prerequisites

  • A Klutch.sh account (sign up here)
  • A GitHub repository for your WordPress project (can be a fork of the official WordPress Docker repo)
  • Basic knowledge of Docker and Git
  • A MySQL or MariaDB database (can be provisioned separately on Klutch.sh or another provider)

1. Prepare Your WordPress Project

Clone the official WordPress Docker example or create your own repository:

Terminal window
git clone https://github.com/docker-library/wordpress.git
cd wordpress

You can customize the files as needed for your site.


2. Sample Dockerfile

Here’s a simple Dockerfile for WordPress (usually provided in the official repo):

FROM wordpress:latest
# Optional: Copy custom themes or plugins
# COPY ./themes /var/www/html/wp-content/themes
# COPY ./plugins /var/www/html/wp-content/plugins
# Expose the default WordPress port
EXPOSE 80

3. Set Up Your Database

WordPress requires a MySQL-compatible database. If you don’t already have one, follow the MySQL deployment guide for Klutch.sh to provision a managed MySQL instance.

Once your database is ready, note the connection details for the next step.


4. Configure Environment Variables

Set the following environment variables in your Klutch.sh app settings:

  • WORDPRESS_DB_HOST (the hostname of your database)
  • WORDPRESS_DB_USER (your database username)
  • WORDPRESS_DB_PASSWORD (your database password)
  • WORDPRESS_DB_NAME (your database name)

5. Deploy to Klutch.sh

  1. Push your code (including Dockerfile) to your GitHub repository.
  2. In the Klutch.sh dashboard, create a new app and connect your repository.
  3. Set the build context and Dockerfile path if different from the root.
  4. Set the app port to 80 (or the port exposed in your Dockerfile).
  5. Add the required environment variables.
  6. Click “Create” to deploy. Klutch.sh will build and run your WordPress container.

6. Post-Deployment

  • Access your WordPress site using the provided Klutch.sh URL.
  • Complete the WordPress installation wizard in your browser.
  • (Optional) Connect a custom domain via the Klutch.sh dashboard.

Resources