・ MAMP ・ XAMPP ・ Local par volant ・ Docker ・ Wocker Le plus simple est probablement le troisième local par volant. Dans mon cas, je ne pouvais pas utiliser les trois premiers sur mon PC (MacOS 13), j'ai donc étudié comment le faire avec Docker.
(Référence: Débutant | Création d'un environnement local pour WordPress, MySQL et phpMyAdmin avec Docker-Compose) Pour ceux qui se sentent comme Docker ... ??, Kame-san's Docker Super Introduction ① ~ Qu'est-ce que Docker? ~ [Pour les débutants] Je pense que vous devriez d'abord étudier.
Créer un fichier yml dans le fichier projet
terminal.
$ touch docker-compose.yml
Copiez ce qui suit dans le fichier yml
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
Essayez d'accéder à http: // localhost: 8080 /, et si l'écran de gestion de wordpress est affiché, c'est ok.