07 CMS Setup - Jermmyy/IT-Landscape GitHub Wiki
CMS Setup - WordPress with Docker
In this section, I’ll walk you through the complete setup process of WordPress using Docker. This includes starting the necessary containers (WordPress and MySQL), configuring volumes, and verifying everything works.
Step-by-Step setup Instructions
Create a project Directory
Create a folder for your WordPress project to keep things organized.
mkdir wordpress-docker
cd wordpress-docker
docker-compose.yml
File
Create a Inside your project folder, create a file named docker-compose.yml
with the following content:
version: '3.9'
services:
db:
image: mysql:5.7
container_name: wordpress-db
restart: always
environment:
MYSQL_DATABASE: wordpress
MYSQL_USER: wp_user
MYSQL_PASSWORD: wp_pass
MYSQL_ROOT_PASSWORD: root_pass
volumes:
- db_data:/var/lib/mysql
wordpress:
image: wordpress:latest
container_name: wordpress-app
depends_on:
- db
ports:
- "8000:80"
restart: always
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_NAME: wordpress
WORDPRESS_DB_USER: wp_user
WORDPRESS_DB_PASSWORD: wp_pass
volumes:
- wordpress_data:/var/www/html
volumes:
db_data:
wordpress_data:
What this does:
- Build and runs MySQL and WordPress containers
- Maps port
8000
on your machine to port80
in the WordPress container - Uses environment variables to set up the WordPress connection to MySQL
Run the Containers
Start everything using Docker Compose:
docker-compose up -d
You should see output indicating that both containers are up and running.
Open WordPress in Your Browser
Visit http://localhost:8000 in your browser.
You should see the WordPress installation screen:
Follow the installation wizard to set your site title, admin user, and password.
Troubleshooting Tips
If you encounter issues, check the following:
- Use
docker ps
to verify containers are running. - Use
docker-compose logs
to view detailed logs. - Make sure port
8000
isn’t in use by another service. - Rebuild with
docker-compose down -v && docker-compose up -d
to reset everything.