WooCommerce Docker Local Environment With SSL
Creates a local development environment powered by Docker and the Woodby Docker4WordPress project. Includes a wealth of useful tools, including Mailhog for capturing emails, PhpMyAdmin for managing MariaDB database, Portainer for managing Docker, Redis for caching, and Xdebug for stack tracing. Powered by NginX, PHP7.2, Redis caching and SSL to best reflect production environments.
Install and launch Docker Community Edition onto your workstation, if not already available. Note: Windows Home Edition is not supported.
Setting It Up
- Download this project to a folder on your workstation.
- Add the URLs to your
sudo nano /etc/hosts; 127.0.0.1 localhost mailhog phpmyadmin portainer
- Make an SSL certificate using one of these methods, store
localhost.crtinto the folder
certs/within your project
- Option 1 - Steps to make a self-signed certificate, for local sandboxes:
openssl genrsa -des3 -passout pass:x -out localhost.pass.key 2048; openssl rsa -passin pass:x -in localhost.pass.key -out localhost.key; rm localhost.pass.key; openssl req -new -key localhost.key -out localhost.csr; openssl x509 -req -sha256 -days 365 -in localhost.csr -signkey localhost.key -out localhost.crt;
- Option 2 - Steps to obtain an SSL certificate from LetsEncrypt.org, if using a real domain or subdomain:
sudo add-apt-repository ppa:certbot/certbot; sudo apt update; sudo apt install certbot; sudo certbot certonly --manual -d *.mydomain.com --agree-tos --no-bootstrap --manual-public-ip-logging-ok --preferred-challenges dns-01 --server https://acme-v02.api.letsencrypt.org/directory;
- If you're using a self-signed certificate, add it into your OS's Keychain App and set it to Always Trust to prevent browsers throwing security warnings.
docker-compose up -dto have docker download the images and bring your system online.
- Point your browser to
https://localhost/and set-up WordPress and WooCommerce to your liking.
- Your web root is located in the
codebase/folder inside the project folder.
This was tested on the latest MacOS. Windows Professional Edition users may need some configuration changes. Refer to the Docker4WordPress Instructions.
Access to tools:
https://localhost/takes you to the local site.
http://mailhog/traps all outbound emails and lets you view them.
http://phpmyadmin/is for managing the database.
http://portainer/is for managing the docker images, containers, etc.
Docker4WordPress commands (execute from inside project folder):
docker-compose stopto stop the services
docker-compose logsto view logs, append
-fto watch them in realtime
docker-compose exec php shto shell into the container
You can set-up multiple instances by creating multiple project folders containing the
docker-compose.yml file and bringing up a
traefik.yml file in the parent folder. I recommend taking the simpler approach whenever possible. Note that folder names matter as they are used for the container naming. Instructions can be found here.
If you want Redis object cache to run, install a caching plugin that uses Redis and add the following line into your
define( 'WP_REDIS_HOST', 'redis' );
- Coded Commerce, LLC - Initial work - Coded-Commerce-LLC
This project is licensed under the MIT License - see the LICENSE file for details