如何配置 Docker wpdiaries/wordpress-xdebug:latest with VS Code PHP Debug?
How to configure Docker wpdiaries/wordpress-xdebug:latest with VS Code PHP Debug?
我想配置 VS Code Xdebug 插件以在 WordPress Docker 容器内使用 Xdebug。
我的端口有问题。
如果我在 docker-compose.yml 文件的“端口”部分中指定 WP-with-Xdebug 容器:
- "9009:9000"
和在同一个容器上的环境变量XDEBUG_CONFIG中:
XDEBUG_CONFIG: remote_host=172.17.0.1 mode=debug start_with_request=true client_port=9000
然后在 VS Code 插件配置的 launch.json 文件中,我放了这一行:
"port": 9009
然后,当我 运行 docker-compose down
然后 docker-compose up
时,我看到 docker-compose up 日志是好的,里面没有错误。然后我点击选项“Listen for Xdebug”前的绿色播放图标,我收到消息框:
listen EADDRINUSE: address already in use :::9009
我认为带有Xdebug的WP容器和VS Code插件都想在主机9009上使用相同的端口来做同样的事情,互相发送信息,但我不明白为什么他们不要成功。
我没有把 phpinfo()
的输出放在这里,因为它包含合理的信息。
我使用:
- https://marketplace.visualstudio.com/items?itemName=felixfbecker.php-debug
- https://github.com/xdebug/vscode-php-debug
wpdiaries/wordpress-xdebug:latest
Docker 图片 (https://hub.docker.com/r/wpdiaries/wordpress-xdebug or https://github.com/wpdiaries/wordpress-xdebug)
- Xdebug v3
- 最新稳定版 WordPress 和 PHP v8.0.3
我没有尝试太多,只是尝试了一点:https://github.com/mac-cain13/xdebug-helper-for-chrome 我认为它在这个问题上对我没有帮助。
这是我的 docker-compose.yml:
的过滤版本
version: '3.3'
services:
db:
container_name: "db_1"
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
restart: "no"
environment:
MYSQL_DATABASE: "wordpress"
MYSQL_USER: "root"
MYSQL_ROOT_PASSWORD: "9821379"
wordpress:
container_name: "wordpress_1"
depends_on:
- db
image: wpdiaries/wordpress-xdebug:latest
ports:
- "80:80"
- "9009:9000"
volumes:
- type: bind
source: ./html
target: /var/www/html
volume:
nocopy: true
restart: "no"
environment:
WORDPRESS_DB_NAME: "wordpress"
WORDPRESS_DB_USER: "root"
WORDPRESS_DB_PASSWORD: "9821379"
WORDPRESS_DB_HOST: db:3306
WORDPRESS_TABLE_PREFIX: 'wp_'
XDEBUG_CONFIG: remote_host=172.17.0.1 mode=debug start_with_request=true client_port=9000
phpmyadmin:
container_name: "phpmyadmin_1"
depends_on:
- db
restart: "no"
ports:
- "8080:80"
image: phpmyadmin/phpmyadmin
environment:
PMA_HOST: db:3306
PMA_USER: "root"
PMA_PORT: 3306
PMA_PASSWORD: "9821379"
volumes:
db_data: {}
这是我的 launch.json 文件:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Listen for Xdebug",
"type": "php",
"request": "launch",
"port": 9009,
"pathMappings": {
"/var/www/html": "${workspaceFolder}/html"
}
},
// the following is not used and not updated:
{
"name": "Launch currently open script",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 9003
}
]
}
我或多或少尝试过的文章:
- https://dev.to/natterstefan/docker-tip-how-to-get-host-s-ip-address-inside-a-docker-container-5anh
- https://dzone.com/articles/setup-wordpress-debug-environment-with-docker-and
- https://www.wpdiaries.com/wordpress-with-xdebug-for-docker/#using-a-ready-made-image
我重新启动了我的笔记本电脑,同样的问题再次出现。
直到我对此做出反应 post 我想我会阅读这里的文档:https://xdebug.org/docs/step_debug.
I think that both the WP container with Xdebug in it and the VS Code plugin want to use the same port on the host 9009
是的,一针见血。建立连接的是 Xdebug,因此没有理由像 incoming 连接那样在 WordPress 容器上公开 9000/9009 端口.您可以删除该公开行。
我想配置 VS Code Xdebug 插件以在 WordPress Docker 容器内使用 Xdebug。
我的端口有问题。
如果我在 docker-compose.yml 文件的“端口”部分中指定 WP-with-Xdebug 容器:
- "9009:9000"
和在同一个容器上的环境变量XDEBUG_CONFIG中:
XDEBUG_CONFIG: remote_host=172.17.0.1 mode=debug start_with_request=true client_port=9000
然后在 VS Code 插件配置的 launch.json 文件中,我放了这一行:
"port": 9009
然后,当我 运行 docker-compose down
然后 docker-compose up
时,我看到 docker-compose up 日志是好的,里面没有错误。然后我点击选项“Listen for Xdebug”前的绿色播放图标,我收到消息框:
listen EADDRINUSE: address already in use :::9009
我认为带有Xdebug的WP容器和VS Code插件都想在主机9009上使用相同的端口来做同样的事情,互相发送信息,但我不明白为什么他们不要成功。
我没有把 phpinfo()
的输出放在这里,因为它包含合理的信息。
我使用:
- https://marketplace.visualstudio.com/items?itemName=felixfbecker.php-debug
- https://github.com/xdebug/vscode-php-debug
wpdiaries/wordpress-xdebug:latest
Docker 图片 (https://hub.docker.com/r/wpdiaries/wordpress-xdebug or https://github.com/wpdiaries/wordpress-xdebug)- Xdebug v3
- 最新稳定版 WordPress 和 PHP v8.0.3
我没有尝试太多,只是尝试了一点:https://github.com/mac-cain13/xdebug-helper-for-chrome 我认为它在这个问题上对我没有帮助。
这是我的 docker-compose.yml:
的过滤版本version: '3.3'
services:
db:
container_name: "db_1"
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
restart: "no"
environment:
MYSQL_DATABASE: "wordpress"
MYSQL_USER: "root"
MYSQL_ROOT_PASSWORD: "9821379"
wordpress:
container_name: "wordpress_1"
depends_on:
- db
image: wpdiaries/wordpress-xdebug:latest
ports:
- "80:80"
- "9009:9000"
volumes:
- type: bind
source: ./html
target: /var/www/html
volume:
nocopy: true
restart: "no"
environment:
WORDPRESS_DB_NAME: "wordpress"
WORDPRESS_DB_USER: "root"
WORDPRESS_DB_PASSWORD: "9821379"
WORDPRESS_DB_HOST: db:3306
WORDPRESS_TABLE_PREFIX: 'wp_'
XDEBUG_CONFIG: remote_host=172.17.0.1 mode=debug start_with_request=true client_port=9000
phpmyadmin:
container_name: "phpmyadmin_1"
depends_on:
- db
restart: "no"
ports:
- "8080:80"
image: phpmyadmin/phpmyadmin
environment:
PMA_HOST: db:3306
PMA_USER: "root"
PMA_PORT: 3306
PMA_PASSWORD: "9821379"
volumes:
db_data: {}
这是我的 launch.json 文件:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Listen for Xdebug",
"type": "php",
"request": "launch",
"port": 9009,
"pathMappings": {
"/var/www/html": "${workspaceFolder}/html"
}
},
// the following is not used and not updated:
{
"name": "Launch currently open script",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 9003
}
]
}
我或多或少尝试过的文章:
- https://dev.to/natterstefan/docker-tip-how-to-get-host-s-ip-address-inside-a-docker-container-5anh
- https://dzone.com/articles/setup-wordpress-debug-environment-with-docker-and
- https://www.wpdiaries.com/wordpress-with-xdebug-for-docker/#using-a-ready-made-image
我重新启动了我的笔记本电脑,同样的问题再次出现。
直到我对此做出反应 post 我想我会阅读这里的文档:https://xdebug.org/docs/step_debug.
I think that both the WP container with Xdebug in it and the VS Code plugin want to use the same port on the host 9009
是的,一针见血。建立连接的是 Xdebug,因此没有理由像 incoming 连接那样在 WordPress 容器上公开 9000/9009 端口.您可以删除该公开行。