Php xdebug连接拒绝Docker容器
错误: 无法与xdebug建立连接。 Docker配置是从这里获取的 xdebug是单独安装的,它由IDE识别 在php fpm环境下的docker-compose.yml中还添加了以下内容:Php xdebug连接拒绝Docker容器,php,docker,nginx,docker-compose,xdebug,Php,Docker,Nginx,Docker Compose,Xdebug,错误: 无法与xdebug建立连接。 Docker配置是从这里获取的 xdebug是单独安装的,它由IDE识别 在php fpm环境下的docker-compose.yml中还添加了以下内容: 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, re
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.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
还有什么需要添加/修改的?这就是我最近为http服务设置docker+php+xdebug的方式。我指导我的同龄人完成了这项工作,结果完美无瑕 1.将ENV PHP_IDE_CONFIG添加到docker fpm池配置中 您需要将此环境添加到php fpm池配置中。它可以是
www.conf
(例如)
2.将xdebug.ini添加到docker容器
下面是我用于设置的xdebug.ini的一个示例:
env[PHP_IDE_CONFIG] = "serverName=localhost"
3.[IntelliJ IDEA或PHPStorm]-设置PHP服务器
首选项
语言和框架
->PHP
->服务器
PHP\u IDE\u CONFIG
值)使用路径映射
/var/www/html
),以便IntelliJ能够正确映射路径首选项
Languages&Frameworks
->PHP
->Debug
->DGBp proxy
- 将
添加到您的url或?XDEBUG\u SESSION=PHPSTORM
- 添加一个名为
且值为XDBEUG\u SESSION
PHPSTORM
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.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
我知道这篇文章是为PHPStorm用户写的,但是如果有任何VSCode用户在这里偶然发现,那么PHPStorm需要做两件不同的事情(更多关于PHPStorm的回答)-
host.docker.internal
{
“名称”:“调试Docker”,
“类型”:“php”,
“请求”:“启动”,
“港口”:9000,
“路径映射”:{
“/var/www/app”:“${workspaceFolder}”
}
},
将
/var/www/app
替换为您自己的路径 你在docker日志中还看到了什么?你能粘贴你的xdebug.ini配置和PHPStorm的xdebug调试端口以及DBGp代理设置吗?你能在这里提供你的xdebug设置吗?这里的第2部分是最重要的,因为调试器需要知道调试开始时连接到什么。具有描述主机、容器和IDE如何互连的架构。这篇文章的作者给出的答案是详尽的。