Netbeans Xdebug Vagrant连接超时

5

我正在尝试使用Netbeans连接到一个通过PuPHPet配置的Vagrant虚拟机上,并为PHP启用xdebug。

以下是我的虚拟机中php.ini的设置:

[XDEBUG]
xdebug.remote_connect_back=1
xdebug.default_enable=1
xdebug.remote_autostart=0
xdebug.max_nesting_level=256
xdebug.remote_enable=1
xdebug.remote_log=/tmp/php5-xdebug.log
xdebug.remote_port=9000
xdebug.remote_handler=dbgp
xdebug.idekey=netbeans-xdebug

Netbeans已经正确地设置了路径映射以运行本地网站,并使用GET变量正确启动浏览器进行调试。我的Windows防火墙允许Netbeans,并且我添加了一条规则,允许从我的VM IP到我的本地IP的所有内容(两个192.168.56.x地址,因此是正确的子网)。
从我的VM中,我可以正常ping通我的主机操作系统。但在xdebug日志中,我只看到:
Log opened at 2014-08-23 17:43:28
I: Checking remote connect back address.
I: Remote address found, connecting to 192.168.56.1:9000.
E: Time-out connecting to client. :-(
Log closed at 2014-08-23 17:43:28

在我的主机操作系统上,我尝试使用netstat,并验证了Netbeans正在监听9000端口。因为我读到不需要这样做(最初我有这个问题,但是Netbeans抱怨有其他的东西在监听9000),所以我在Virtualbox中删除了9000端口转发。
我意识到php-fpm也使用9000端口,所以我尝试使用9001端口(在ini文件中进行更改并重新启动了php-fpm,在IDE中也验证了IDE现在正在监听9001)。但结果相同。
I: Checking remote connect back address.
I: Remote address found, connecting to 192.168.56.1:9001.
E: Time-out connecting to client. :-(
Log closed at 2014-08-23 18:11:59

所以现在我已经阅读了所有内容,但我卡住了。有什么想法吗?
1个回答

6

在我发布帖子的时候,我找到了答案:

$ netstat -r
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
10.0.2.0        *               255.255.255.0   U         0 0          0 eth0
192.168.56.0    *               255.255.255.0   U         0 0          0 eth1
link-local      *               255.255.0.0     U         0 0          0 eth0
link-local      *               255.255.0.0     U         0 0          0 eth1
default         10.0.2.2        0.0.0.0         UG        0 0          0 eth0

请注意最后一行。因此我进行了更改:
xdebug.remote_connect_back=1

to

xdebug.remote_host=10.0.2.2

在php-fpm重启后立即生效!


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接