Docker Compose to set up containers
See docker compose https://github.com/kasakun/wordpress-nginx-docker.
Nginx is the front end, in the mean time WordPress and MySQL serve as a standalone server. This gives me ability to add more service in future easily.
Before starting the container with docker-compose, we need to edit .env to customize data and SSL location. Sometimes we need chmod permission for these folders for WordPress to write in.
docker-compose up -d # start all containers
docker-compose down # stop all containers
docker logs wp-* # check containers' logs to understand it works correctly
Auto SSL
Here we use acme script from https://github.com/acmesh-official/acme.sh.
After installation, we can go ahead to verify the domain and the server — we need to specify the server webroot in the command:
acme.sh --issue -d example.com -d www.example.com -d cp.example.com -w $WEBROOT
The $WEBROOT is defined in the .env above. After running this command, it will issue a certificate and meanwhile set up a cron job. This can be checked by:
crontab -l