A development Docker environment for WordPress with Xdebug integration for debugging.
- WordPress with PHP 8.2
- MySQL 8.0
- phpMyAdmin
- Xdebug for debugging
- SSL support
- Persistent MySQL data
- Volume mounting for live code updates
- Content seeding with fake posts
- WordPress installation script
- Environment reset capability
- Development directory structure
- Docker
- Docker Compose
- Git
- Clone the repository:
git clone https://github.com/jaredchu/wordpress-dev-dockercompose.git wordpress-dev
cd wordpress-dev
- Set up environment:
cp .env.dev .env
cp ./config/xdebug.ini.dev ./config/xdebug.ini
- Start the containers:
docker-compose up -d
- Install WordPress:
./scripts/install.sh
- Access your WordPress site at:
- WordPress: https://localhost
- phpMyAdmin: https://localhost:8080
- (Optional) Seed the database with fake content:
./scripts/seed.sh
Service | URL | Default Credentials |
---|---|---|
WordPress | https://localhost | Create during setup |
phpMyAdmin | https://localhost:8080 | root / (from .env) |
- Code Changes: Edit files in the
wordpress
directory - Database Access: Use phpMyAdmin at port 8080
- Debugging: Configure your IDE to use Xdebug (port 9003)
- Content Seeding: Use
./scripts/seed.sh
to generate fake posts - Environment Reset: Use
./scripts/reset.sh
to start fresh
dev/
directory. Any code stored inside wordpress/
directory will be removed when running reset.sh
.
.
├── dev/ # Development directory (SAFE - preserved on reset)
│ ├── plugins/ # Development plugins
│ └── themes/ # Development themes
└── wordpress/ # WordPress installation (WILL BE RESET)
Directory purposes:
dev/
: Contains development files that are NOT part of the WordPress installation. This is the ONLY safe place for your code.wordpress/
: Contains a fresh WordPress installation that can be reset anytime. Do not store development files here.
Key variables in .env
:
MYSQL_ROOT_PASSWORD
: Database root passwordMYSQL_USER
: WordPress database userMYSQL_PASSWORD
: WordPress database passwordPHP_XDEBUG_BRANCH
: Xdebug version to install
-
Configure Xdebug in your IDE:
- Port: 9003
- Host: localhost
- Path mappings:
/var/www/html
→./wordpress
-
Enable debugging in browser:
- Install Xdebug browser extension
- Toggle debugging when needed
-
Container won't start:
docker-compose down -v docker-compose up -d
-
Permission issues:
sudo chown -R $USER:$USER wordpress/
-
Database connection issues:
- Check MySQL service is running
- Verify credentials in .env
- Ensure ports are not blocked
-
Reset environment:
./scripts/reset.sh
- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.