Skip to content

Instantly share code, notes, and snippets.

@MatthewCallis
Created November 5, 2021 01:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MatthewCallis/f77b9bbe566f744bf212cde2dd51e27c to your computer and use it in GitHub Desktop.
Save MatthewCallis/f77b9bbe566f744bf212cde2dd51e27c to your computer and use it in GitHub Desktop.
Simple Local WordPress
  1. Install Docker
  2. Create the docker-compose.yml in the empty directory we want to run the blog from
  3. Run docker-compose up -d from the directory we saved the docker-compose.yml
  4. Wait for everything to install and start
  5. Ensure any additional configuration you have in your production WordPress is in your wp-config.php file, but not the database credentials
  6. Replace the installed WordPress wp-content with your own
  7. Ensure your WordPress database is synced with production, phpMyAdmin is installed on http://localhost:8080
  8. You should now have a working local copy of your blog at http://localhost:8000

Instructions modified from Containerizing WordPress with Docker-Compose

version: "3"
services:
# MySQL Database Image
mysql_database:
platform: linux/x86_64 # Required for Apple M1 chip
image: mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: my_password_1234789
MYSQL_DATABASE: my_wp_database
MYSQL_USER: my_wp_user
MYSQL_PASSWORD: my_wp_user_password
volumes:
- mysql:/var/lib/mysql
# WordPress image based on Apache
wordpress:
depends_on:
- mysql_database
image: wordpress:latest
restart: always
ports:
- "8000:80"
environment:
WORDPRESS_DB_HOST: mysql_database:3306
WORDPRESS_DB_USER: my_wp_user
WORDPRESS_DB_PASSWORD: my_wp_user_password
WORDPRESS_DB_NAME: my_wp_database
volumes:
["./:/var/www/html"]
# phpMyAdmin to manage the MySQL database
phpmyadmin:
depends_on:
- mysql_database
image: phpmyadmin/phpmyadmin
restart: always
ports:
- '8080:80'
environment:
PMA_HOST: mysql_database
MYSQL_ROOT_PASSWORD: my_password_1234789
volumes:
mysql: {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment