How to run Wordpress & Mysql with docker-compose and custom php.ini
engineering
July 18, 2020
Rez Moss
@rezmos11- Copy below code to docker-compose.yml
version: "3.3"
services:
db:
image: mysql:5.7
volumes:
- ${PWD}/db_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: somewordpress
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
wordpress:
depends_on:
- db
image: wordpress:latest
volumes:
- ${PWD}/wordpress_data:/var/www/html
- ./php.ini:/usr/local/etc/php/conf.d/conf.ini
ports:
- "8000:80"
restart: always
environment:
WORDPRESS_DB_HOST: db
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
WORDPRESS_DB_NAME: wordpress
volumes:
db_data: {}
wordpress_data: {}
2- Copy below code to php.ini
file_uploads = On
memory_limit = 500M
upload_max_filesize = 500M
post_max_size = 500M
max_execution_time = 3200
3- Run docker-compose up
4- Above yaml file, will use "wordpress_data" folder in the same directory as file storage and "db_data" folder in the same directory as Mysql storage and Wordpress website exposed on port 8000, which means if you open your browser and enter http://localhost:8000, you should be able to see Wordpress.