Docker+php-fpm+Xdebug(Linux)+ PhpStorm(Windows)

Docker+php-fpm+Xdebug (on Linux) + PhpStorm (on Windows)

我在我的 Linux 主机上安装了 Docker,并使用 php-fpm 和 Xdebug 创建了一个容器。 PhpStorm 安装在 Windows 服务器上。项目通过gitlab吊装。你能告诉我如何在这样的包中通过 Xdebug 设置调试吗?

Docker ver.

Client: Docker Engine - Community
 Version:           19.03.13
 API version:       1.40
 Go version:        go1.13.15
 Git commit:        4484c46d9d
 Built:             Wed Sep 16 17:03:45 2020
 OS/Arch:           linux/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          19.03.13
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.13.15
  Git commit:       4484c46d9d
  Built:            Wed Sep 16 17:02:21 2020
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.3.7
  GitCommit:        8fba4e9a7d01810a393d5d25a3621dc101981175
 runc:
  Version:          1.0.0-rc10
  GitCommit:        dc9208a3303feef5b3839f4323d9beb36df0a9dd
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683

Xdebug 版本。 2.9.8

我需要在没有 DBGp 代理的情况下进行设置。它需要使用路径映射进行配置。这可能吗?

Linux 和 Windows 服务器在同一子网中,但是当我打开页面时 Xdebug 日志中仍然出现超时。

更新。 Xdebug 日志

[79] Log opened at 2021-04-08 06:51:34
[79] I: Checking remote connect back address.
[79] I: Checking header 'HTTP_X_FORWARDED_FOR'.
[79] I: Checking header 'REMOTE_ADDR'.
[79] I: Remote address found, connecting to xx.xx.xx.xx:9000.
[79] E: Time-out connecting to client (Waited: 200 ms). :-(
[79] Log closed at 2021-04-08 06:51:34

我也决定使用DBGP Proxy,但是也有一些问题。已尝试代理 Windows 和 Linux。

[14688] Log opened at 2021-04-08 06:55:25
[14688] I: Checking remote connect back address.
[14688] I: Checking header 'HTTP_X_FORWARDED_FOR'.
[14688] I: Checking header 'REMOTE_ADDR'.
[14688] I: Remote address found, connecting to xx.xx.xx.xx:9000.
[14688] I: Connected to client. :-)
[14688] -> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" fileuri="file:///var/www/html/debug.php" language="PHP" xdebug:language_version="7.3.22" protocol_version="1.0" appid="14688" idekey="OR"><engine version="2.9.8"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[https://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2020 by Derick Rethans]]></copyright></init>

[78] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" status="stopping" reason="ok"></response>

[78] Log closed at 2021-04-08 06:56:11

但它无法通过浏览器和 Postman 运行。并且只有终端中通过 curl 的请求挂起,Linux 上的代理发出以下

Xdebug Simple DBGp client (0.4.2)
Copyright 2019-2020 by Derick Rethans
In dumb client mode

Waiting for debug server to connect on port 9000.
Connect from 192.168.112.4:45638
DBGp/1.0: Xdebug 2.9.8 — For PHP 7.3.22
Debugging file:///var/www/html/debug.php (ID: 78/OR)

感谢大家。问题竟然出在防火墙上。我打开了 9000 端口,它起作用了