Skip to content

parkwoo/wordpress-docker-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WordPress Docker Template

GitHub Repository: git@github.com:parkwoo/wordpress-docker-template.git

Overview

This repository is a template for easily setting up a WordPress development environment using Docker Compose. It provides a complete development environment including MySQL database and WordPress containers.

Setup Instructions

1. Clone the Repository

git clone git@github.com:parkwoo/wordpress-docker-template.git
cd wordpress-docker-template

If you encounter SSH authentication errors: Check your GitHub SSH authentication settings. Use the following commands to check your SSH keys:

# Check for existing SSH keys
ls -al ~/.ssh

# Generate a new SSH key (if needed)
ssh-keygen -t ed25519 -C "your_email@example.com"

# Start the SSH agent and add your key
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519

# Register your public key with GitHub
cat ~/.ssh/id_ed25519.pub

Alternatively, you can clone using HTTPS:

git clone https://github.com/parkwoo/wordpress-docker-template.git

2. Set Environment Variables

Edit the .env file to set environment variables:

# Copy the example env file (or edit if it exists)
cp .env.example .env

Main environment variables:

  • MYSQL_ROOT_PASSWORD: MySQL root password
  • MYSQL_DATABASE: Database name for WordPress
  • MYSQL_USER: Database user for WordPress
  • MYSQL_PASSWORD: Database password for WordPress
  • EXPOSE_PORT: Public port for WordPress (default: 8080)

3. Prepare Directory Structure

Create the necessary directories:

mkdir -p mysql/data mysql/conf
mkdir -p wordpress/themes wordpress/plugins wordpress/uploads

4. Run Docker Compose

# Start the containers
docker-compose up -d

# Check container status
docker-compose ps

# View logs
docker-compose logs -f

Environment Configuration

Services

  • mysql: MySQL 8.0 database
  • wordpress: Latest WordPress

Volume Mounts

  • ./mysql/data → MySQL data persistence
  • ./mysql/conf/custom.cnf → MySQL configuration file
  • ./wordpress/themes → WordPress themes
  • ./wordpress/plugins → WordPress plugins
  • ./wordpress/uploads → Media uploads

Network

  • Uses Docker's default network
  • Containers can communicate using service names

Initial WordPress Setup

  1. Access http://localhost:8080 in your browser
  2. Follow the WordPress installation wizard
  3. Database information:
    • Database Name: wordpress (or the value set in .env)
    • Username: wordpress (or the value set in .env)
    • Password: The value of MYSQL_PASSWORD in your .env file
    • Database Host: mysql
    • Table Prefix: wp_ (default)

Usage for Development

Theme Development

# Place your theme in the themes directory
cp -r your-theme/ wordpress/themes/

Plugin Development

# Place your plugin in the plugins directory
cp -r your-plugin/ wordpress/plugins/

Database Operations

# Connect to the MySQL container
docker-compose exec mysql mysql -u root -p

Container Management

# Stop containers
docker-compose down

# Restart containers
docker-compose restart

# Rebuild images
docker-compose up -d --build

Troubleshooting

Port Conflict

Change the EXPOSE_PORT value in your .env file to use a different port.

Permission Errors

On Linux/Mac:

sudo chown -R 1000:1000 mysql/data wordpress/

Database Connection Errors

Wait until the containers are fully started (may take several tens of seconds).

Customization

Change MySQL Settings

Create or edit mysql/conf/custom.cnf to customize MySQL settings.

Add WordPress Settings

Add environment variables to the wordpress service in docker-compose.yml.

License

This template is provided under the MIT License. See the LICENSE file in the repository for details.

Contribution

Please report bugs or request features via GitHub Issues.

About

A Docker Compose template for rapid provisioning of a WordPress development environment. Delivers a fully functional local stack with MySQL and WordPress containers.

Topics

Resources

Stars

Watchers

Forks

Contributors