Quantcast
Channel: Crafting software» mrdavidlaing
Viewing all articles
Browse latest Browse all 13

HOWTO – configure Netbeans PHP debugging for a remote server, over a SSH tunnel

$
0
0

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.

  1. apt-get install php5-xdebug
  2. 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
    
  3. restart apache2
  4. Create remote->local SSH tunnel ssh -R 9000:127.0.0.1:9000 yourname@yourserver.com
  5. 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

Viewing all articles
Browse latest Browse all 13

Trending Articles