在本地主机上使用Xdebug和Netbeans远程调试PHP网站的正确方法

时间:2012-03-24 17:11:00

标签: php debugging netbeans xdebug

我在使用xdebug和netbeans配置进行远程调试时遇到问题。

我可以在localhost上使用xdebug和netbeans进行调试,但它工作得很好..但是在远程服务器上,当我放置一个断点并调试文件时,它发生了什么,它只是不停在任何断点上。我不知道自从我刚接触到这个以来我错过了什么..这是我到目前为止的基本设置。

在我的php ini文件中

zend_extension = "c:/wamp/bin/php/php5.3.8/zend_ext/php_xdebug-2.1.2-5.3-vc9-x86_64.dll"

[xdebug]
xdebug.remote_enable = 1
xdebug.remote_host=localhost
xdebug.remote_handler = dbgp
xdebug.remote_connect_back = 1
xdebug.profiler_enable = 1
xdebug.profiler_enable_trigger = 1
xdebug.profiler_output_name = cachegrind.out.%t.%p
xdebug.profiler_output_dir = "c:/wamp/tmp"

在我的netbeans上,我已经配置了远程连接,并且这里的连接效果很好是运行配置的设置

Run As = Remote Web Site (FTP, SFTP)
Project Url =  http://www.somewebsite.com/
Index File = index.php
Arguments = none since it has n arguments at first

inside Remote Connection :  
host Name = host IP(eg 69.123.123.123)
encryption = Pure Ftp
username = someuser
password = somepassword
initial directory = /
timeout = 30
keep alive interval = 30
Passive mode = checked

Upload directory = blank
Upload Files = manually

希望有人可以帮助我指出我缺少什么,做什么,我很难理解这方面的一些技术配置,如果你能一步一步地帮助我,我知道我可以效仿。期待着这一点。谢谢!

2 个答案:

答案 0 :(得分:0)

您需要进行路径映射,否则netbeans会在错误的路径上设置断点。如果您创建一个远程日志文件(http://xdebug.org/docs/all_settings#remote_log),您将看到它设置断点的路径。有关路径映射的信息,请参阅https://blogs.oracle.com/netbeansphp/entry/path_mapping_in_php_debugger

答案 1 :(得分:0)

您必须将远程主机设置为运行Netbeans的计算机的名称或IP,而不是localhost。

xdebug.remote_host =本地主机

改为例如:

xdebug.remote_host = 192.168.0.10

原因是,服务器上的Xdebug会尝试连接到您的Netbeans-Machine进行调试 - 而不是相反 - 所以您的服务器需要知道“远程”机器的地址。

哦,还要确保您的本地Windows防火墙允许从端口9000上的服务器进行连接。