Skip to content

Production-ready Docker Compose setup for self-hosting WordPress. This full-featured stack includes MySQL, phpMyAdmin for DB management, WP-CLI for command-line tasks, and a backup script. Pre-configured for security and easy integration with other services.

License

Notifications You must be signed in to change notification settings

AiratTop/wordpress-self-hosted

Repository files navigation

WordPress Self-Hosted with Docker

wordpress-self-hosted

This repository provides a docker compose setup to run a self-hosted WordPress instance, complete with a MySQL database, phpMyAdmin, and WP-CLI.

It is pre-configured to join a shared Docker network, allowing easy integration with other services like n8n.

Features

  • Uses official Docker images for WordPress, MySQL, phpMyAdmin, and WP-CLI.
  • Includes a full-featured environment for development and management.
  • Persists WordPress files and MySQL data in local volumes (./data/wp and ./data/wp-db).
  • Pre-configured for a shared network for easy inter-service communication.
  • Includes helper scripts for easy management (restart-docker.sh, update-docker.sh).
  • Includes a backup.sh script for creating compressed database backups.
  • Includes a sample Caddyfile for use with a reverse proxy.

Getting Started

  1. Clone the repository:

    git clone https://github.com/AiratTop/wordpress-self-hosted.git
    cd wordpress-self-hosted
  2. Create the shared network: If it doesn't exist yet, create the shared Docker network:

    docker network create shared_network
  3. Configure environment variables: Create a .env file and specify your database credentials.

  4. Start the services:

    docker compose up -d

Accessing Services

Usage

  • Start: docker compose up -d
  • Stop: docker compose down
  • Restart: ./restart-docker.sh
  • Update: ./update-docker.sh (Pulls the latest Docker images and restarts)
  • Backup: ./backup.sh (Creates a compressed backup in the backups directory)
  • WP-CLI: Use docker compose exec wp-cli wp <command>. For example:
    # List installed plugins
    docker compose exec wp-cli wp plugin list

Connecting with n8n

This setup is designed to work with the n8n-self-hosted configuration. Since both services are on the shared_network, you can connect to MySQL from n8n using the following credentials:

  • Host: wp-db
  • Port: 3306
  • Database, User, Password: (As specified in your .env file)

See Also

Check out other self-hosted solutions:

License

This project is licensed under the MIT License - see the LICENSE file for details.


Author

Airat Halitov

About

Production-ready Docker Compose setup for self-hosting WordPress. This full-featured stack includes MySQL, phpMyAdmin for DB management, WP-CLI for command-line tasks, and a backup script. Pre-configured for security and easy integration with other services.

Topics

Resources

License

Stars

Watchers

Forks

Languages