Docker environment with WordPress, PHP-FPM, Apache, phpMyAdmin and MariaDB
Use it to develop your plugin or to have a LAMP stack to test some code.
Feel free to use as you wish.
Clone the repository on your local machine or WSL.
(optional, but recommended) Generate self-signed SSL certificates with mkcert
.
In your host machine, install mkcert.
Run: mkcert -cert-file wordpress.local.pem -key-file wordpress.local.key.pem wordpress.local localhost 127.0.0.1 ::1
Run mkcert -install
in the same dir you executed the command above in order to enable the certs in your host machine browsers.
Move the generated .pem
to the path /.docker/wordpress/apache/certs
Run docker compose up --build -d
Lastly, you'll need to add 127.0.0.1 wordpress.local
to your operating system's hosts file. See this tutorial to learn how to access them for Linux and Windows.
In Windows, add the two following lines. For Linux, just the first one:
127.0.0.1 wordpress.local
::1 wordpress.local
Open wordpress.local in your browser.
Open localhost:8080 to access phpMyAdmin in your browser.
Command to run in wp-plugins for both host user and Docker be allowed to edit the files/folders:
sudo chgrp -R www-data wp-plugins/
sudo find wp-plugins/ -type d -exec chmod 0775 {} \;
sudo find wp-plugins/ -type f -exec chmod 0775 {} \;
mariadb
- stores the mariadb data. So, you can run docker compose down
and the database will still be safe here. You may delete /mariadb/data/*
manually to reset the database./wordpress
- stores settings for the WP service./wp-logs
- stores the Apache logs from the WP service./wp-plugins
- it's where you put your plugins. Also, any plugins installed from WordPress will be present here./wp-themes
- it's where you put your themes. Themes intalled from WordPress will be present here too../.docker/wordpress/php/php.ini
: https://github.com/php/php-src/blob/master/php.ini-development