Wordpress Environment Setup
Wordpress require server environment (Apache, Nginx), PHP and access to MySQL or MariaDB for storing information. There are couple options available how we can to start developing wordpress powered websites:
- Buy dedicated hosting space (https://wordpress.com/pricing/)
- Create own server based on Cloud Computing Services Amazon AWS Light Sail or Digital Ocean droplet
- Install on own Apache, Nginx server Linux based computer or raspberry Pi device
- Install PHP development environment on local desktop laptop - XAMPP
- Use popular containerized approach with Docker
I'm going to setup my development environment using Docker. This will remove the hassle of installation and configuration required software on local computer. Instead I will create Docker compose file which use separate image files for (wordpress, php myadmin, and mySQL) and allow for one command set-up of whole environment. All required image files can be found on Docker Hub - library of container images and world's largest community.
All we need to do is to create docker-compose.yaml file in project directory where we include all services (like mySQL database, wordpress and phpmyadmin for easy access to the wordpress tables), volumes - file systems mounted on Docker containers to store data generated by running container. Volumes are stored on the host independently of the container's life cycle which allows for easy back-up and sharing file systems between containers.
Database service
mySQL database requires container image file - mysql:5.7 and some environmental variables like name of the database, password for the root user and separate username and password for use with WordPress data. Name of the docker network (dwt-website) to allow communication between containers on the same network.
WordPress service
WordPress service will be using our database service(db), so line depends_on: must be added, then use the WordPress container image with the latest available version. To be able to access WordPress from the local machine we need to map ports so 8000 on local machine will map to port 80 on docker container. Then we map WordPress apache root folder to the current directory to store the data on local machine. Host for WordPress is db service on port 3306, and environmental variables for wp user and password.
PhpMyAdmin service
Container image name is phpmyadmin/phpmyadmin and we also want to have access to it from the local machine so will map port 8080 to 80 in the container and setup password for the root user.
Let's start
In the terminal or command line go to the directory with the docker-compose.yaml file and run the docker-compose up -d (detached) command. If containers are not available on the local machine it will be downloaded from the docker hub page (might take some time during first run).
To check running containers we can use docker ps command
Now just open the web browser and type localhost:8000 to start the set-up of the wordpress site.

Comments
Post a Comment