xdebug连接被拒绝到Docker容器。

问题描述 投票:2回答:1

错误。

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.commartinphamsymfony-5-docker-treemasterdocker。

xdebug是单独安装的,IDE可以识别。

同时在php-fpm环境下的docker-compose.yml中添加了这个。

environment:
- XDEBUG_CONFIG:remote_host=host.docker.internal remote_enable=1 remote_autostart=off xdebug.idekey=PHPSTORM

还有什么需要添加修改的?

php docker nginx docker-compose xdebug
1个回答
2
投票

这是我最近设置http-services的docker+php+xdebug的方法。我指导同行们做了一遍,效果很好。

1. 在你的docker fpm池配置中添加ENV PHP_IDE_CONFIG。

你需要将这个环境添加到你的php-pm池配置中。它可以是 www.conf (举例来说)

env[PHP_IDE_CONFIG] = "serverName=localhost"

2. 将xdebug.ini添加到你的docker容器中。

下面是我用来设置的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

3. IntelliJ IDEA 或 PHPStorm] - 设置 PHP 服务器

  1. 开放式 Preferences
  2. 前往 Languages & Frameworks -> PHP -> Servers
  3. 设置 名称本地主机 (这一点很重要,应该与 PHP_IDE_CONFIG 价值)
  4. 设置 主机本地主机
  5. 启用 use path mappings
  6. 将您的项目根路径映射到 docker 工作目录(例如 /var/www/html),这样IntelliJ就可以正确地映射这些路径。

4. IntelliJ IDEA或PHPStorm]--设置IDE键。

  1. 开放式 Preferences
  2. 前往 Languages & Frameworks -> PHP -> -> -> -&gt Debug -> DGBp proxy
  3. 设置 IDE键PHPSTORM

5. 在你的urlcookie中加入XDEBUG_SESSION=PHPSTORM,。

最后在你的urlcookie中添加XDEBUG_SESSION=PHPSTORM。

  • 在你的urlcookie中添加一个 ?XDEBUG_SESSION=PHPSTORM 到你的url或
  • 添加一个名为 XDBEUG_SESSION 和价值 PHPSTORM

2
投票

问题是在:环境中。

- XDEBUG_CONFIG:remote_host=host.docker.internal remote_enable=1 remote_autostart=off xdebug.idekey=PHPSTORM
  1. 它没有被正确解析。
  2. 如果我只传递 remote_host=host.docker.internal,那么它将传递 "localhost "而不是主机的 IP 地址。
© www.soinside.com 2019 - 2024. All rights reserved.