【问题标题】:Docker+php-fpm+Xdebug (on Linux) + PhpStorm (on Windows)Docker+php-fpm+Xdebug (Linux) + PhpStorm (Windows)
【发布时间】:2021-04-06 18:43:56
【问题描述】:

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

Docker 版

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 日志中仍然出现超时。

UPD。 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)

【问题讨论】:

  • 首先,在任何路径映射之前,您的带有 XDebug/WebServer 的 Docker 容器应该能够与外部网络和特定的 Windows IDE 机器通信。你介意我问一下 XDebug 是否能够建立与 IDE 的 TCP9000 连接吗?你能分享一下 XDebug 日志 sn-p 吗?

标签: php docker phpstorm xdebug


【解决方案1】:

谢谢大家。问题出在防火墙上。我打开了 9000 端口,它工作了

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-01-07
    • 2014-08-29
    • 2019-04-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多