使用 xDebug 在虚拟机上调试项目


Debug project on Virtual Machine with xDebug

我有一个由Vagrant设置的虚拟机。这是Centos 7。除了Apache和mod_php我安装了xDebug,它的配置如下所示:

[xdebug]
zend_extension="/usr/lib64/php/modules/xdebug.so"
xdebug.remote_enable = On
xdebug.remote_autostart = On
xdebug.remote_handler = dbgp
xdebug.remote_port = 9000
xdebug.remote_mode = req
xdebug.remote_connect_back = On
xdebug.idekey = "netbeans-xdebug"

为我的项目设置了一个虚拟主机,当我在浏览器中将其拉出时,我让它正常工作。 xDebug 完美运行。

然后我想使用 Vagrant Share 使我的项目可以从互联网访问。当我启动此服务时,该网站可通过 my-temporary-domain.vagrantshare.com 使用。一切似乎都很好。但我无法调试。

我看不到的问题是什么?我应该配置什么才能让 xDebug 完成它的工作?

所以我找到了解决方案。

我的来宾计算机具有静态 IP 192.168.1.2。我的主机一 -- 192.168.1.1当我设置

xdebug.remote_connect_back = Off 

这是默认的,顺便说一句。并制作

xdebug.remote_host = 192.168.1.1

它按预期工作。我认为这是因为我没有完全理解的xDebug概念。本文帮助:http://walkah.net/blog/debugging-php-with-vagrant/