・ 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.
(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