远程服务器的 Xdebug 未连接

2021-12-26 00:00:00 php xdebug netbeans

我希望使用不同计算机的团队能够在远程服务器上调试 PHP,但是我很难让 Xdebug 在 NetBeans 7.0.1 中工作.我尝试了很多在线提示,但都无济于事.

作为记录,我已经在运行 WampServer 的 Windows 7 机器上成功地本地安装了 Xdebug.所以我可以在 NetBeans 中使用断点调试 PHP,前提是我将 Project Properties->Run Configuration->Run As 属性设置为 Local Web Site.但是,如上所述,我的目标是在 远程网站 上的 NetBeans 中进行调试.

我的服务器是 Ubuntu 11.04 机器.我使用了

因此,您需要相应地设置服务器,方法是告诉它连接到特定 IP 地址(xdebug.remote_host)或自动重新连接"" (xdebug.remote_connect_back).不过,后者有一些安全隐患.这些在手册中有概述.

I want a team using different computers to be able to debug PHP on a remote server, but I am having a hard time getting Xdebug to work in NetBeans 7.0.1. I’ve tried many online tips, but to no avail.

For the record, I have successfully installed Xdebug locally on a Windows 7 machine running WampServer. So I can debug PHP with breakpoints in NetBeans, provided I set the Project Properties->Run Configuration->Run As property to Local Web Site. However, as stated above my goal is to debug in NetBeans on a Remote Web Site.

My server is a Ubuntu 11.04 machine. I have used the output from http://www.xdebug.org/find-binary.php to put the proper binary on the machine. I have modified all php.ini files I could find (in both the php5/apache2 and php5/cli directories) to include these lines:

zend_extension="/usr/lib/php5/20090626+lfs/xdebug.so"
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_host=localhost
xdebug.remote_port=9000

If I check the phpinfo.php web page, it says:

This program makes use of the Zend Scripting Language Engine:
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
    with Xdebug v2.1.2, Copyright (c) 2002-2011, by Derick Rethans

So Xdebug does seem to be installed properly. Still, when I try debugging in NetBeans, I get the endless status bar message Waiting For Connection (netbeans-xdebug). When I hit the stop button I get No connection from xdebug was detected within X seconds. The reason could be that xdebug is not installed or not properly configured.

Maybe I'm confusing local settings with server settings here? A post said xdebug.remote_host should be set to the IP of the machine running NetBeans, but I want a team to be able to debug using machines with different IP addresses. A problem could be port 9000, but I have checked that it is not blocked.

Any help that could clarify this would be appreciated!

解决方案

The server running PHP (and XDebug) needs to be able to connect to your workstation/desktop.

So you'll need the server set up accordingly by either telling it to connect to a specific IP-address (xdebug.remote_host) or to automatically "connect back" (xdebug.remote_connect_back). The latter has some security implications, though. These are outlined in the manual.

相关文章