You can also use WordPress in Docker for a quick local setup, or to use on a container-based environment, like Netlify who are free for small projects. Here is a feature about using WordPress on Netlify: https://www.netlify.com/with/wordpress/
Using a docker-compose.yml
based on the quickstart instructions, you can install and connect two local servers, an Apache webserver with PHP and WordPress, and a MySQL database server, all by running docker-compose up
.
Then you can use your local WordPress setup in your browser on http://localhost
.
If you want to test older WordPress versions, you can change image: 'wordpress:latest'
and replace latest
with one of the docker images available on docker hub, like image: 'wordpress:4.8-php7.0-apache'
.
The following example is a local docker-compose
setup I used to develop a WordPress plugin, so I have added another docker volume for my plugin folder.
version: '3.3'
services:
db:
container_name: 'local-wordpress-db'
image: 'mysql:5.7'
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'
# image: 'wordpress:4.8-php7.0-apache'
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"
- "./my-plugin-name:/var/www/html/wp-content/plugins"
hosts
file and add some fake domains to it like127.0.0.1[tab]site1.dev[enter]127.0.0.1[tab]site2.dev
. This way you have actual dev domains and don't have to work with any relative paths or directories.