Introduction
WordPress is a popular content management system used to create websites and blogs. Docker Compose is a tool for defining and running multi-container Docker applications. In this guide, we'll walk through the steps to install WordPress using Docker Compose on Ubuntu.
Prerequisites
Before proceeding, ensure you have:
- An Ubuntu server with Docker and Docker Compose installed
- Basic knowledge of Docker and Docker Compose
Steps to Install WordPress with Docker Compose
- Create a Docker Compose file: Create a new directory for your WordPress project and create a
docker-compose.yml
file:
mkdir wordpress
cd wordpress
nano docker-compose.yml
- Configure Docker Compose: Add the following configuration to the
docker-compose.yml
file:
version: '3.7'
services:
db:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: your_mysql_root_password
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: your_wordpress_db_password
wordpress:
depends_on:
- db
image: wordpress:latest
ports:
- "8000:80"
restart: always
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: your_wordpress_db_password
WORDPRESS_DB_NAME: wordpress
volumes:
db_data: {}
Replace your_mysql_root_password
and your_wordpress_db_password
with your desired MySQL root and WordPress database passwords.
- Start Docker Compose: Use the following command to start the WordPress containers:
docker-compose up -d
- Access WordPress: Open a web browser and navigate to
http://localhost:8000
to access the WordPress installation wizard and complete the setup.
Conclusion
Congratulations! You have successfully installed WordPress using Docker Compose on your Ubuntu server. You can now start building your website or blog with WordPress.