NetBeans Xdebug远程主机等待连接的时间无限制

yduiuuwa  于 2022-11-10  发布在  其他
关注(0)|答案(1)|浏览(170)

我正在尝试将Xdebug配置到我的NetBeans IDE中,它显示为“等待连接”。我已经花了两天时间,但我没有找到它的线索。

  • 我正在使用SFTP连接从NetBeans IDE连接到远程服务器中的代码,该连接是成功的。
  • 我的远程服务器是一个安装了Cent OS 7的虚拟机。
  • 我的应用程序配置了nginx,PHP-FPM,PHP 5.6.

我已经在服务器中安装了xdebug-2. 5. 5,并在php.ini中添加了以下内容:

zend_extension=/apps/php-fpm/lib/php/extensions/no-debug-non-zts-20131226/xdebug.so
xdebug.remote_autostart=0
xdebug.remote_enable=1
xdebug.remote_handler="dbgp"
xdebug.remote_mode="req"
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.idekey="netbeans-xdebug"
;xdebug.remote_connect_back=1
xdebug.profiler_enable_trigger=0
xdebug.remote_log="/mypath/xdebug.log"

我已经交叉检查了xdebug.so位于我上面提到的正确路径中。
在我的NetBeans中,工具〉〉选项〉〉PHP〉〉调试:

Debugging port:  9000
Session ID: netbeans-xdebug

当我在NetBeans IDE中启动调试时,我看到了以下日志:

Log opened at 2021-11-24 07:11:45
I: Connecting to configured address/port: localhost:9000.
I: Connected to client. :-)
-> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" fileuri="file:///myserver/location/path/index.php" language="PHP" xdebug:language_version="5.6.14" protocol_version="1.0" appid="4643" idekey="netbeans-xdebug"><engine version="2.5.5"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[http://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2017 by Derick Rethans]]></copyright></init>

-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" status="break" reason="ok"><xdebug:message filename="file:///myserver/location/path/index.php" lineno="13"></xdebug:message></response>

-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" status="stopping" reason="ok"></response>

Log closed at 2021-11-24 07:11:45

而在NetBeans IDE中,“等待连接”将无限期地持续加载。
我正在寻找一些帮助,以了解这方面的问题是什么。我没有使用任何Docker和PhpStorm。期待一些帮助。

gudnpqoy

gudnpqoy1#

您说“我的远程服务器是一个安装了Cent OS 7的虚拟机”,但您却有xdebug.remote_host=localhost
Xdebug是连接到IDE的接口,而不是其他接口。如果你的代码运行在另一台服务器上(另一台物理机器,或者在虚拟机或某个容器中),那么xdebug.remote_host应该指向你的IDE运行的机器(一个IP地址或域名,可以解析为该IP;从该服务器上可以看到)。* 当然,除非您正在为Xdebug连接使用反向SSH隧道。*
现在您正在连接到服务器上TCP 9000端口上的某个服务。它很可能是php-fpm(也使用该端口:这就是Xdebug v3将默认端口更改为9003 BTW的原因之一)。您的Xdebug日志非常短:了解Xdebug工作方式的服务的典型响应是关闭会话。php-fpm可以完成此操作。
以下是几点建议:

  • 要确保只有Xdebug正在使用此端口:在php.ini和NetBeans中将Xdebug端口号更改为另一个数字(例如9001或更好的9003,这样它将与Xdebug v3兼容)。之后不要忘记重新启动Web服务器/php-fpm(使用phpinfo();检查实时设置)。
  • 如果没有使用反向SSH隧道,则将xdebug.remote_host设置为具有NetBeans的计算机的IP。通常,这与$_SERVER['REMOTE_HOST']中看到的IP相同。

注意:由于这是一个传入连接,您本地操作系统、服务器和路由器(如果位于LAN之外)上的防火墙可以阻止此类连接。因此,您需要确保您可以在本地机器的Xdebug端口上接收传入连接。

相关问题