I'm in the process of setting up a Vagrant environment using puppet for provisioning.
I'm stuck with one issue, I would like xdebug to 'just work' when running vagrant up
however I need to specify the host machines ip address in the php.ini file xdebug.remote_host
, obviously this is going to be different on each machine the config is used so I would like a way to automatically update that value when issuing vagrant up
.
VagrantFile:
config.vm.network :forwarded_port, guest: 9000, host: 9000
.ini settings:
'xdebug.default_enable=1',
'xdebug.remote_enable=1',
'xdebug.remote_handler=dbgp',
'xdebug.remote_host=localhost:9000',
'xdebug.remote_port=9000',
'xdebug.remote_autostart=0',
'xdebug.max_nesting_level=250'
I have also tried it with xdebug.remote_host=localhost
ifconfig results from the vagrant machine:
vagrant@precise64 ~ : ifconfig
eth0 Link encap:Ethernet HWaddr 00:0c:29:cf:f9:89
inet addr:192.168.61.142 Bcast:192.168.61.255 Mask:255.255.255.0
phpinfo()
REMOTE_ADDR 192.168.61.2
REMOTE_PORT 51886
Just to confirm, if I give remote_host
my actual ip address I have on my osx host machine, it works correctly.
As mentioned in http://www.xdebug.org/docs/all_settings, you can set option
So, xdebug will connect back to the host, which requested for web-page, and will ignore option "remote_host".
This solution has one problem: If you enable xdebug for any request, and user, opening web-page doesn't have running xdebug client (waiting for connection from server), and has non-closed
9000
port, the server would wait for a long time (trying to connect to client's xdebug session), before it can finally load page. I had this problem with windows 7 machines, because it's firewall doesn't actually closes port, and connecting software can't understand, that nobody is listening port.If this doesn't work:
I had the same situation, then I was need for VirtualBox VM with configuration, that should work on any machine with any IP. So, I made it this way:
192.168.100.1
, so, my REAL machine have two addresses:eth0:192.168.1.2
, andvboxnet0:192.168.100.1
.IP=192.168.100.100
, Default gateway =192.168.100.1
remote_ip=192.168.100.1
And now, I have 3 copies of this machine (my copy, and 2 copies used by my co-workers), and it works fine!
So, solution is to set your IP address to some "constant one", just virtually.