How to Use xdebug and vagrant
Our xdebug configuration in the Vagrant machine
From this article: Vagrant: A box with Drupal 7 simpleSAMLphp. We have xdebug installed in our Vagrant machine.
Let's configure it. Connecting to the Vagrant Machine.
$ cd vagrantrepo & vagrant ssh
Editing 'php.ini'. In the vagrant machine we'll edit 20-xdebug.ini since it is where Nginx is storing the xdebug settings
sudo vi /etc/php5/fpm/conf.d/20-xdebug.ini
zend_extension=xdebug.so xdebug.remote_enable = on xdebug.remote_connect_back = on xdebug.idekey = "vagrant"
Restarting Ngix
sudo service php5-fpm restart
Debuging from SublimeText or PHPStorm:
I don't want to dive into how to install and enable xdebug in SublimeText or PHPStorm.
Follow the following tutorial for ST: webdevstudios.com
And this one for PHPStorm: https://confluence.jetbrains.com/
Tunneling into the remote server
We have two "ways" to create the tunnel to the Vagrant machine.
1.- Using the regular ssh command
ssh -R 9000:localhost:9000 vagrant@192.168.33.99; the password is 'vagrant' as usual.
2.- Using the vagrant ssh command
vagrant ssh -- -R 9000:localhost:9000 Don't forget to execute it from the Vagrant repo/folder.
Trobleshoothing
We are absolute sure that the tunnel is stablished executing $ netstat -nlt | grep 9000. The output should look like this:
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN tcp6 0 0 ::1:9000 :::* LISTEN
If still the above output is blank. Try disabling the FireWall
sudo ufw disable
TODOs
Open FW only for the port 9000.