Install Docker.io and Docker Compose:
sudo apt install docker.io docker-compose
References:
- https://developer.yoast.com/blog/set-up-wordpress-development-environment-in-docker/
- https://themeisle.com/blog/local-wordpress-development-using-docker/
Create a new folder for your WordPress/WooCommerce local development project.
Create docker-compose.yml
for mariadb
(use same version as AWS RDS MariaDB) and wordpress
services:
---
version: '3.3'
services:
db:
container_name: 'local-wordpress-db'
image: 'mariadb:10.4'
volumes:
- './data/mysql:/var/lib/mysql'
ports:
- 18766:3306
environment:
MYSQL_ROOT_PASSWORD: somewordpress
MYSQL_DATABASE: wordpress_db
MYSQL_USER: wordpress_user
MYSQL_PASSWORD: wordpress_password
wordpress:
container_name: 'local-wordpress'
depends_on:
- db
image: 'wordpress:latest'
ports:
- '80:80'
environment:
WORDPRESS_DB_HOST: 'db:3306'
WORDPRESS_DB_USER: wordpress_user
WORDPRESS_DB_PASSWORD: wordpress_password
WORDPRESS_DB_NAME: wordpress_db
volumes:
- "./wordpress:/var/www/html"
- "./plugins:/var/www/html/wp-content/plugins"
Start the containers:
docker-compose up
Go to http://localhost/ and you’ll see WordPress installation screen.
Simple Plugin
In plugins/ folder, create a new folder “hello-wordpress
” then create “hello-wordpress.php
” there for simple plugin:
<?php
/*
Plugin Name: Hello WordPress
Plugin URI: http://wordpress.org/plugins/hello-wordpress/
Description: Hello WordPress!
Author: John Doe
Version: 1.0.0
Author URI: http://example.org/
*/
In WordPress, go to Plugins list and now you should see “Hello WordPress” there.