Hosting the WordPress Dev Environment
My first inclination for WordPress dev environment was to look for free cloud hosting the could support Wordpress. I was least inclined to install directly onto my laptop, and deal with potentially conflincting with my other local dev environments. Given that I already have Docker For Mac running, I decided to go the Docker route.
WordPress on Docker
To learn how to setup Wordpress on Docker, I followed this, that, and the other guide.
Below is the docker-compose.yml file used to setup WordPress, MySql, and PhpMyAdmin. The main features:
- DB data persisted in a docker volume named wp_db_data
- Wordpress site files stored on host in the wp folder
- PhpMyAdmin in it's own container to manage the DB
version: '2'
services:
db:
image: mysql:5.7
volumes:
- wp_db_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: somerootpassword
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
wordpress:
depends_on:
- db
image: wordpress:latest
volumes:
- ./wp:/var/www/html
ports:
- "8000:80"
restart: always
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
phpmyadmin:
depends_on:
- db
image: phpmyadmin/phpmyadmin
container_name: phpmyadmin
environment:
- PMA_ARBITRARY=1
- PMA_HOST=db
restart: always
ports:
- 8080:80
volumes:
- /sessions
volumes:
wp_db_data:
Create a directory where you want the Wordpress site to exist, eg:
mkdir -p ~/dev/wpdocker/wp
cd ~/dev/wpdocker
vi docker-compose.yml
# copy the contents above, edit as needed, then:
docker-compose up
Point your browser at localhost:8000, and you should see the initial WordPresss install dialog:
Follow through the basic installation, and you should be rewarded with something like this: