[英]xdebug connection refused to Docker container
错误:
2020/04/26 23:43:48 [error] 8#8: *2 connect() failed (111: Connection refused) while connecting to upstream, client: 192.168.208.1, server: localhost, request: "GET /favicon.ico HTTP/1.1", upstream: "fastcgi://192.168.208.3:9000", host: "127.0.0.1", referrer: "http://127.0.0.1/"
无法与 xdebug 建立连接。 Docker 配置取自这里https://gitlab.com/martinpham/symfony-5-docker/-/tree/master/docker
xdebug 是单独安装的,它被 IDE 识别。
在 php-fpm 环境下的 docker-compose.yml 中也添加了这个:
environment:
- XDEBUG_CONFIG:remote_host=host.docker.internal remote_enable=1 remote_autostart=off xdebug.idekey=PHPSTORM
还需要添加/修改什么?
这就是我最近为 http 服务设置 docker + php + xdebug 的方式。 我指导我的同龄人完成了它,它完美无缺。
您需要将此环境添加到您的 php-fpm 池配置中。 它可能是www.conf
(例如)
env[PHP_IDE_CONFIG] = "serverName=localhost"
这是我用于设置的 xdebug.ini 示例:
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
xdebug.remote_connect_back = off
xdebug.remote_host = host.docker.internal
xdebug.remote_port = 9000
xdebug.idekey = PHPSTORM
xdebug.max_nesting_level = 1500
Preferences
Languages & Frameworks
-> PHP
-> Servers
PHP_IDE_CONFIG
值匹配)use path mappings
/var/www/html
),因此 IntelliJ 可以正确 map 路径。Preferences
Languages & Frameworks
-> PHP
-> Debug
-> DGBp proxy
最后:
?XDEBUG_SESSION=PHPSTORM
到您的 url 或XDBEUG_SESSION
和值PHPSTORM
的 cookie问题出现在:环境:
- XDEBUG_CONFIG:remote_host=host.docker.internal remote_enable=1 remote_autostart=off xdebug.idekey=PHPSTORM
我知道这篇文章是针对 PHPStorm 用户的,但是如果任何 VSCode 用户在这里偶然发现,那么需要做两件与 PHPStorm 不同的事情(更多内容请参见 PHPStorm https://stackoverflow.com/a/61561910/3056278的答案)-
host.docker.internal
{
"name": "Debug Docker",
"type": "php",
"request": "launch",
"port": 9000,
"pathMappings": {
"/var/www/app": "${workspaceFolder}"
}
},
将/var/www/app
替换为您自己的路径!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.