This repository contains Docker Compose configuration for setting up WordPress with MySQL database.
- Docker
- Docker Compose
-
Clone this repository
git clone <repository-url> cd wordpress
-
Copy the environment file
cp .env.example .env
-
Configure the environment variables in
.env
:WORDPRESS_PORT
: Port for WordPress site (default: 80)MYSQL_ROOT_PASSWORD
: MySQL root passwordMYSQL_PASSWORD
: WordPress database user password
-
Start the containers
docker-compose up -d
WORDPRESS_PORT
: Port for WordPress site (default: 80)WORDPRESS_IMAGE
: WordPress Docker image version
MYSQL_IMAGE
: MySQL version (default: 5.7)MYSQL_ROOT_PASSWORD
: Root password for MySQLMYSQL_DATABASE
: Database name for WordPressMYSQL_USER
: Database user for WordPressMYSQL_PASSWORD
: Database password for WordPress
WORDPRESS_DEBUG
: WordPress debug modeWORDPRESS_CONFIG_EXTRA
: Additional WordPress configurationsTZ
: Timezone (default: Asia/Taipei)
CONTAINER_DB
: MySQL container nameCONTAINER_WP
: WordPress container name
.
├── data/
│ ├── db/ # MySQL data
│ └── wp/ # WordPress files
├── .env.example
├── docker-compose.yml
└── README.md
-
Access WordPress:
http://localhost:<WORDPRESS_PORT>
-
Start containers:
docker-compose up -d
-
Stop containers:
docker-compose down
-
View logs:
docker-compose logs -f
All data is stored in the data
directory:
data/db
: MySQL database filesdata/wp
: WordPress files and uploads
To backup your WordPress installation, you can copy or archive these directories. This ensures you have a complete backup of both your database and WordPress files.