Running WordPress on PHP-5.6 with MySQL-5.7 on Docker container
- PHP for my site was updated to 7.2, but that broke my (long-time-not-updated) wordpress setup
- Have an export of your db ; name the file
./wordpress.sql
- Have a copy of your entire wordpress installation ; put it in ./public_html/
- Create an empty folder ./db_data
- Create a file
./.env
(*1) - (optional) add line to sql (*2)
- run
- when all is running, change base url to
localhost:8080
(*3)
(*1) .env
file should look something like this:
MYSQL_ROOT_PASSWORD=wordpress
MYSQL_DATABASE=wordpress
MYSQL_USER=wordpress
MYSQL_PASSWORD=wordpress
(I filled in the actual values I used on the server)
(*2) My database could not load the ./wordpress.sql script. I needed to add the following line to the top of ./wordpress.sql
SET SQL_MODE='ALLOW_INVALID_DATES';
(*3) Open phpmyadmin(http://localhost:8090/) and change in table wp_options
- home
- siteurl
to localhost:8080
instead of your-domain.com
Or you can change the sql file for those entries:
# old
INSERT INTO `wp_options` VALUES("1","siteurl","http://your-domain.com","yes");
# new
INSERT INTO `wp_options` VALUES("1","siteurl","http://localhost:8080","yes");
# old
INSERT INTO `wp_options` VALUES("37","home","http://your-domain.com","yes");
# new
INSERT INTO `wp_options` VALUES("37","home","http://localhost:8080","yes");
Building image
docker-compose build
Running containers:
docker-compose up
docker-compose exec wordpress bash
docker-compose down