使用VirtualBox远程Xdebug

Zac*_*ach 9 virtualbox remote-debugging xdebug

我正在尝试远程调试工作.PHP正在VM上运行,我正在尝试从主机上的NetBeans进行调试.

我按照这里的说明,转发了Windows 7防火墙和VirtualBox网络设置中的端口9000,并在NetBeans中设置了路径映射.我的xdebug设置如下所示:

xdebug.remote_enable = On
xdebug.remote_connect_back = On
xdebug.idekey = "netbeans-xdebug"
xdebug.remote_log = /tmp/xdebug.log
Run Code Online (Sandbox Code Playgroud)

当我加载我想调试的URL(使用正确的idekey)时,它会记录以下内容:

I: Checking remote connect back address.
I: Remote address found, connecting to 192.168.0.1:9000.
I: Connected to client. :-)
-> <init xmlns="urn:debugger_protocol_v1" 
         xmlns:xdebug="http://xdebug.org/dbgp/xdebug"
         fileuri="file:///home/dev/web/projects/project.com.vm/httpdocs/index.php" 
         language="PHP" protocol_version="1.0" 
         appid="1380" 
         idekey="netbeans-xdebug">
   <engine version="2.2.1"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[http://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2012 by Derick Rethans]]></copyright></init>

-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" status="stopping" reason="ok"></response>
Run Code Online (Sandbox Code Playgroud)

但是,NetBeans仍在等待连接.除了设置断点之外,我已将其设置为在第一行停止.即使NetBeans未侦听,日志文件也将包含"已连接到客户端"消息.

知道我可能会缺少什么吗?

谢谢.

ada*_*man 7

对我有用的是从我的主机运行以下内容:

ssh -R 9000:localhost:9000 yourUserName@yourVirtualMachine
Run Code Online (Sandbox Code Playgroud)

注意使用-R标志而不​​是-L.我无法使用端口转发来使事情正常工作,而ssh隧道工作得很好.请注意,您也可以通过从VM中运行ssh命令并使用-L标志连接到主机来执行此操作.

由于我在使用Vagrant时最终得到了这个问题,这是我个人使用的命令,在提示时使用密码'vagrant':

ssh -p 2222 vagrant@127.0.0.1 -R 9000:localhost:9000
Run Code Online (Sandbox Code Playgroud)


小智 5

我对此问题的解决方案如下:

1)在网络配置中启用端口转发(使用NAT适配器)我只使用端口9000以及主机和来宾的IP地址.协议是TCP

2)配置我的xdebug设置:在我的情况下,重要的是设置xdebug.remote_host ="永久主机IP"然后everthing完美地工作.

希望这有助于那里的人.


Llo*_*ore 1

虚拟机需要能够与主机进行对话,要实现这一点,您需要转发 9000 来执行此操作。某些设置中未描述此步骤,因为它发生在后台。

为此,请发出命令 ssh -L 9000:localhost:9000 yourUserName@youVirtualMachine。

为了简化这一点,我在 /etc/hosts 和 ~/ssh/config 文件中保存了虚拟机的名称。