Wordpress local environment construction & development procedure with Docker

Choices when you want to build a local Wordpress environment

・ MAMP ・ XAMPP ・ Local by flywheel ・ Docker ・ Wocker Probably the easiest is the third Local by flywheel. In my case, I couldn't use the former three on my PC (MacOS13), so I investigated how to do it with Docker.

Build a local environment with Docker

(Reference: Beginner | Building a local environment for WordPress, MySQL and phpMyAdmin with Docker-Compose) For those who feel like Docker ... ??, Kame-san's Docker Super Introduction ① ~ What is Docker? ~ [For beginners] I think you should study first.

Create a yml file inside the project file

terminal.


$ touch docker-compose.yml

Copy and paste the following into the yml file

docker-compose.yml


version: "3"
services:
  db:
    image: mysql:5.7
    #container_name: "mysql57"
    volumes:
      - ./db/mysql:/var/lib/mysql
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: root_pass_fB3uWvTS
      MYSQL_DATABASE: wordpress_db
      MYSQL_USER: user
      MYSQL_PASSWORD: user_pass_Ck6uTvrQ

  wordpress:
    image: wordpress:latest
    #container_name: "wordpress"
    volumes:
      - ./wordpress/html:/var/www/html
      - ./php/php.ini:/usr/local/etc/php/conf.d/php.ini
    restart: always
    depends_on:
      - db
    ports:
      - 8080:80
    environment:
      WORDPRESS_DB_HOST: db:3306
      WORDPRESS_DB_NAME: wordpress_db
      WORDPRESS_DB_USER: user
      WORDPRESS_DB_PASSWORD: user_pass_Ck6uTvrQ

  phpmyadmin:
    image: phpmyadmin/phpmyadmin:latest
    #container_name: "phpmyadmin"
    restart: always
    depends_on:
      - db
    ports:
      - 8888:80

docker-compose.yml



version: '3.7'

networks:
  wordpress:
    ipam:
      config:
        - subnet: 172.25.0.0/16

services:

  # here is out mysql database
  db:
    image: mysql:5.7
    volumes:
      - ./db:/var/lib/mysql:delegated
      # - ./docker/db-dumps:/docker-entrypoint-initdb.d:delegated
    ports:
      - "3306:3306"
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: somewordpress
      MYSQL_DATABASE: wordpress
      MYSQL_USER: wordpress
      MYSQL_PASSWORD: wordpress
    networks:
      - wordpress

  # here is our wordpress server
  wordpress:
    depends_on:
      - db
    image: wordpress:latest
    volumes:
      # our persistent local data re routing
      - .:/var/www/html/wp-content/themes/testing:delegated
      - ./plugins:/var/www/html/wp-content/plugins
      - ./uploads:/var/www/html/wp-content/uploads
      - ./uploads.ini:/usr/local/etc/php/conf.d/uploads.ini
    ports:
      - "80:80"
    restart: always
    networks:
      - wordpress
    environment:
      # our local dev environment
      WORDPRESS_DEBUG: 1
      DEVELOPMENT: 1
      # docker wp config settings
      WORDPRESS_DB_HOST: db:3306
      WORDPRESS_DB_USER: wordpress
      WORDPRESS_DB_PASSWORD: wordpress
      WORDPRESS_DB_NAME: wordpress
      WORDPRESS_AUTH_KEY: 5f6ede1b94d25a2294e29eeba929a8c80a5ac0fb
      WORDPRESS_SECURE_KEY: 5f6ede1b94d25a2294e29eeba929a8c80a5ac0fb
      WORDPRESS_LOGGED_IN_KEY: 5f6ede1b94d25a2294e29eeba929a8c80a5ac0fb
      WORDPRESS_NONCE_KEY: 5f6ede1b94d25a2294e29eeba929a8c80a5ac0fb
      WORDPRESS_SECURE_AUTH_SALT: 5f6ede1b94d25a2294e29eeba929a8c80a5ac0fb
      WORDPRESS_LOGGED_IN_SALT: 5f6ede1b94d25a2294e29eeba929a8c80a5ac0fb
      WORDPRESS_NONCE_SALT: 5f6ede1b94d25a2294e29eeba929a8c80a5ac0fb
      WORDPRESS_CONFIG_EXTRA: |

        /* Development parameters */
        define('WP_CACHE', false);
        define('ENVIRONMENT', 'local');
        define('WP_DEBUG', true);

        /* Configure mail server */
        define('WORDPRESS_SMTP_AUTH', false);
        define('WORDPRESS_SMTP_SECURE', '');
        define('WORDPRESS_SMTP_HOST', 'mailhog');
        define('WORDPRESS_SMTP_PORT', '1025');
        define('WORDPRESS_SMTP_USERNAME', null);
        define('WORDPRESS_SMTP_PASSWORD', null);
        define('WORDPRESS_SMTP_FROM', '[email protected]');
        define('WORDPRESS_SMTP_FROM_NAME', 'Whoever');

        /* add any more custom wp-config defines here */

  # here is our mail hog server
  mailhog:
    image: mailhog/mailhog:latest
    ports:
      - "8025:8025"
    networks:
      - wordpress

Up docker-compose

terminal.


$ docker-compose up -d

Try accessing http: // localhost: 8080 /, and if the wordpress management screen is displayed, it's ok.

Recommended Posts

Wordpress local environment construction & development procedure with Docker
Laravel development environment construction with Docker (Mac)
Build a Wordpress development environment with Docker
Build a WordPress development environment quickly with Docker
[Docker] Rails 5.2 environment construction with docker
React environment construction with Docker
Build WordPress environment with Docker (Local) and AWS (Production)
Rails + MySQL environment construction with Docker
Node.js environment construction with Docker Compose
Build Couchbase local environment with Docker
Environment construction with Docker for beginners
[Unity] Android development environment construction procedure
Rails on Docker environment construction procedure
[Environment construction with Docker] Rails 6 & MySQL 8
Rails application development environment construction with Docker [Docker, Rails, Puma, Nginx, MySQL]
CentOS8 + Anaconda + Django development environment construction procedure
Rails environment construction with Docker (personal apocalypse)
Sapper × Go (echo) × Docker development environment construction
Build a PureScript development environment with Docker
Environment construction with Docker (Ubuntu20.04) + Laravel + nginx
Create Spring Boot-gradle-mysql development environment with Docker
[Docker] Development environment construction Rails6 / Ruby2.7 / MySQL8
Spring Boot + Docker Java development environment construction
Laravel + MySQL + phpMyadmin environment construction with Docker
Lightweight PHP 7.4 development environment created with Docker
Ruby on Rails development environment construction with Docker + VSCode (Remote Container)
PostgreSQL environment construction with Docker (from setup to just before development)
"Rails 6 x MySQL 8" Docker environment construction procedure for sharing with teams
Build debug environment on container --Build local development environment for Rails tutorial with Docker-
Spring Boot environment construction with Docker (January 2021 version)
Docker + DynamoDB local + C ++ environment construction and practice
[Jakarta EE 8 application development with Gradle] 1. Environment construction
Rails Docker environment construction
Environment construction command memo with Docker on AWS
Rails6 [API mode] + MySQL5.7 environment construction with Docker
Build a local development environment for Rails tutorials with Docker (Rails 6 + PostgreSQL + Webpack)
java development environment construction
A reminder of Docker and development environment construction
React + Django + Nginx + MySQL environment construction with Docker
[First team development ②] Build an environment with Docker
Create a Spring Boot development environment with docker
BEAR application Docker development environment construction example (docker-sync, Mutagen)
Stable development environment construction manual for "Rails6" with "Docker-compose"
[First team development ③] Share the development environment created with Docker
[Java] Environment construction procedure for developing struts 1.3 with Eclipse
Build Java development environment with WSL2 Docker VS Code
[Environment construction] Build a Java development environment with VS Code!
Database environment construction with Docker in Spring boot (IntellJ)
Debug the VSCode + Docker + PHP development environment with XDebug.
Java + Spring development environment construction with VirtualBox + Ubuntu (Xfce4)
Create Chisel development environment with Windows10 + WSL2 + VScode + Docker
Pytorch execution environment with Docker
Rails6 development environment construction [Mac]
WSL2 + VSCode + Docker development environment
EC-CUBE4 environment construction (local edition)
MySQL 5.7 (Docker) environment construction memo
Redmine (Docker) environment construction memo
Build docker environment with WSL
Docker × Spring Boot environment construction
[Docker] postgres, pgadmin4 environment construction
Build DynamoDB local with Docker