1. 修改 docker-compose.yml
把端口映射由8080:80改为8090:80,保存
2. 更改站点配置
1)通过数据库更改配置
docker exec -it mysql_container mysql -u root -proot1234
In MySQL:
USE wordpress;
SET SQL_SAFE_UPDATES=1;
UPDATE wp_options SET option_value = 'http://localhost:8090' WHERE option_name IN ('siteurl', 'home');
UPDATE wp_posts SET post_content = REPLACE(post_content, 'http://localhost:8080', 'http://localhost:8090');
UPDATE wp_postmeta SET meta_value = REPLACE(meta_value, 'http://localhost:8080', 'http://localhost:8090');
SET SQL_SAFE_UPDATES=0;
2) 通过源代码文件更改配置
Update in wp-config.php
cat wordpress_data/wp-config.php | grep -E 'WP_HOME|WP_SITEURL'
如果存在则继续,否则没有存在该配置文件中。
- Edit the WordPress configuration in the container:
docker exec -it wordpress_container bash
nano /var/www/html/wp-config.php
- Update these lines if existing
define('WP_HOME', 'http://localhost:8090');
define('WP_SITEURL', 'http://localhost:8090');
重启服务
`docker-compose restart wordpress`