Having tripped myself up on multiple occasions setting this up, I’m recording these config steps here for future-me.
Scenario: You have a PHP site running on a remote [Ubuntu 12.04] server, and want to connect your local IDE [Netbeans] to the Xdebug running on that server over a SSH tunnel.
- apt-get install php5-xdebug
- vi /etc/php5/apache2/conf.d/xdebug.ini
zend_extension=/usr/lib/php5/20090626/xdebug.so xdebug.remote_enable=On xdebug.remote_host=127.0.0.1 xdebug.remote_port=9000 xdebug.remote_handler=dbgp
- restart apache2
- Create remote->local SSH tunnel ssh -R 9000:127.0.0.1:9000 [email protected]
- Launch Netbeans debugger
The key is that your Netbeans IDE acts as the server in this scenario, listening for incoming connections to port 9000 from the remote server’s XDebug. Thus the tunnel must be from the remote port to your local port, not the other way around.
Some helpful debugging technques
Start ssh with -vv for debugging output
netstat -an | grep 9000
should show something like:
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN tcp 0 0 127.0.0.1:9000 127.0.0.1:59083 ESTABLISHED tcp 0 0 127.0.0.1:59083 127.0.0.1:9000 ESTABLISHED tcp6 0 0 ::1:9000 :::* LISTEN
Is it a way to remote debug with local (windows platform) and remote (Ubuntu 12.04)?
Remote debug does not work on Ubuntu 12.04 but it was working on Ubuntu 10.04
These instructions are for a local Mac OS, and a remote Ubuntu 12.04 server.
For Windows, you should be able to create the tunnel using a SSH client like Putty.
Thanks for the post, it saved me a lot of time and headache trying to figure out if it could be done. I configured my remote Ubuntu 10 development server to connect back to my Windows workstation running Netbeans over a Putty SSH tunnel for PHP debugging.
Thank you very much for the post. everything worked like a charm. Its still valid for Ubuntu 14.04