Setting up a local WordPress environment is one of the fastest and safest ways to test plugins, themes, or build new client sites without risking a live server. In this guide, I’ll walk you through how to install WordPress locally using Docker — the modern developer’s tool of choice.
Whether you’re a freelance web developer in Melbourne or a marketing coordinator from Perth trying to prototype a campaign landing page, this method will work seamlessly on your machine.
Prefer watching over reading? You can check out the full tutorial on YouTube in the player below.
Or if you’re more of an old-school type who likes a proper walkthrough in text — just scroll down. Everything’s laid out step by step, like back in the good days of real how-to blogs.
Table of Contents
- Why Install WordPress Locally?
- Local Installation Options for WordPress
- Prerequisites
- Step-by-Step: Local WordPress Installation Using Docker
- MySQL Performance Tuning for WordPress
- Frequently Asked Questions
- Download Ready-to-Use Project
- Final Thoughts
Why Install WordPress Locally?
- Full control over the environment (PHP version, extensions, mail handling)
- Zero hosting costs
- Instant reloads and file access
- No risk of breaking production
Local Installation Options for WordPress
Tool | Type | Pros | Cons |
---|---|---|---|
Docker | Container-based | Configurable, reproducible, modern dev standards | Requires terminal knowledge, initial setup |
XAMPP | App bundle | Easy GUI, quick start for beginners | Hard to version control, conflicts with other services |
MAMP | App bundle | Popular on Mac, simple interface | Free version lacks advanced features |
LocalWP | Specialised tool | Zero-config, good for designers | Less flexible, can be resource-heavy |
Vagrant | VM-based | Isolation, full OS-level control | Slower performance, higher resource usage |
Prerequisites
- Docker Desktop installed (Mac, Windows, Linux)
- Basic knowledge of terminal or command prompt
Step-by-Step: Local WordPress Installation Using Docker
1. Create Project Structure
mkdir my-wp-dev && cd my-wp-dev
mkdir wordpress php-config mysql-config
echo "upload_max_filesize=64M\npost_max_size=64M" > php-config/php.ini
2. Set Up .env File
COMPOSE_PROJECT_NAME=mywp
PROJECT_PORT=8000
PMA_PORT=8080
MAILHOG_HTTP_PORT=8025
MAILHOG_SMTP_PORT=1025
WORDPRESS_DB_NAME=wordpress
WORDPRESS_DB_USER=wordpress
WORDPRESS_DB_PASSWORD=wordpress
MYSQL_ROOT_PASSWORD=root
3. docker-compose.yml Configuration
version: '3.8'
services:
wordpress:
image: wordpress:latest
ports:
- "${PROJECT_PORT:-8000}:80" # Host:Container — WordPress UI
volumes:
- ./wordpress:/var/www/html
- ./php-config/php.ini:/usr/local/etc/php/conf.d/custom.ini
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: ${WORDPRESS_DB_USER}
WORDPRESS_DB_PASSWORD: ${WORDPRESS_DB_PASSWORD}
WORDPRESS_DB_NAME: ${WORDPRESS_DB_NAME}
depends_on:
- db
- mailhog
db:
image: mysql:8.0
restart: always
command: --default-authentication-plugin=mysql_native_password
environment:
MYSQL_DATABASE: ${WORDPRESS_DB_NAME}
MYSQL_USER: ${WORDPRESS_DB_USER}
MYSQL_PASSWORD: ${WORDPRESS_DB_PASSWORD}
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
volumes:
- ./mysql-data:/var/lib/mysql
- ./mysql-config:/etc/mysql/conf.d
phpmyadmin:
image: phpmyadmin/phpmyadmin
restart: always
ports:
- "${PMA_PORT:-8080}:80" # phpMyAdmin access on localhost
environment:
PMA_HOST: db
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
depends_on:
- db
mailhog:
image: mailhog/mailhog
ports:
- "${MAILHOG_HTTP_PORT:-8025}:8025" # MailHog web UI
- "${MAILHOG_SMTP_PORT:-1025}:1025" # MailHog SMTP (for WP emails)
4. Launch Containers
docker-compose up -d
5. Access WordPress and Developer Tools
- WordPress: http://localhost:8000
- phpMyAdmin: http://localhost:8080
- MailHog: http://localhost:8025
Create a file to inspect PHP:
<?php phpinfo(); ?>
MySQL Performance Tuning for WordPress
Create file mysql-config/wp.cnf
with:
[mysqld]
max_allowed_packet = 64M
innodb_buffer_pool_size = 256M
innodb_log_file_size = 128M
default_authentication_plugin = mysql_native_password
sql_mode = ""
This improves large DB imports, plugin compatibility, and query reliability.
Frequently Asked Questions
How is Docker better than XAMPP or MAMP?
- Environment is reproducible across teams
- Can be committed to version control
- No conflicts with host OS services
Can I run multiple projects?
Yes. Use different COMPOSE_PROJECT_NAME
and port values in .env
.
Can I access the database?
Yes, via:
- phpMyAdmin: http://localhost:8080
- MySQL CLI client: host
localhost
, userwordpress
, passwordpress
Can I test emails locally?
Yes. MailHog captures WordPress emails: http://localhost:8025
Download Ready-to-Use Project
You can download the full ready-to-use project on GitHub:
👉 https://github.com/gynsus/wordpress-docker-local-dev
Final Thoughts
With Docker, you get a full WordPress stack locally in minutes. It’s easy to set up, fast to use, and ideal for any developer or marketer working with WordPress daily.