Overview
KB
PHP Manual
CSS2 Manual
HTML Manual
JS Guide
JS Reference
Technical FAQ
PhpDock Manual
Nu-Coder Manual
PhpExpress Manual
PHP Joomla
Development
Learn PHP
 
<Run debug sessionSet project mapping for debugging>
Last updated: Wed, 02 Feb 2011

Remote PHP Debugging with SSH tunnel

Setting up your system to debug php scripts can be tricky. Fortunately PhpED's Project Settings Wizard can take care of the majority of the debugging configurations. Just create a project if you havn't created one, run the Wizard, and it will guide you through all necessary steps in order to install and configure your project and debugger module, then check the results. For the details, please read php dbg wizard page

If you want to debug your scripts on a public server, or your server is located in a different network so it can not connect to your development machine, you have to perform additional steps in order to provide a way for the debugger module on the server to work with the PhpED IDE. We recommend to run Project Settings Wizard first and check whether it shows same or different network in client outbound IP line in the results. In case of same, debugger module can work with IDE and only firewalls should be configured to permit communication on the debugger port. In case of different networks, you need either establish port forwarding on the NAT router or run ssh with reverse tunnel (a kind of data channel).

In this article we will look into working with PHP Debugger and answer the following questions:
  • How to setup PHP Debugger with SSH tunnel?
  • How to setup PHP Debugger with the router?
More about NuSphere PHP Debugger (including video tutorials) is available at http://www.nusphere.com/products/php_debugger.htm

Setup remote debugging with NuSphere PhpED

This article is part of FAQ for PHP Debugger available in PhpED - NuSphere PHP IDE
Another way to work with remote debugger is to use SSH tunnel. This tunnel is a kind of data channel that opens with regular ssh session. It will transfer data between debugger module and IDE.

1. Make sure that SSH daemon (sshd) is running on your server. It's a common tool for all unix/linux based servers. If you're using Windows, you may want to try openssh service that comes with Cygwin
2. Start PhpED. On Tools->Settings->Run & Debug->settings page, please check "Override client address" checkbox. Enter localhost into the "client address" input. Port should match the tunnel's listening port which is 7869 in our case.
3. open php.ini on the server and make sure that debugger.hosts_allow contains localhost:
debugger.hosts_allow=localhost 127.0.0.1
debugger.hosts_deny=ALL
debugger.ports=7869, 10000/16
You don't need any other addresses here because debugger module will connect to the tunnel's socket which is local to the server.
4. run ssh on your client computer and connect it to the server using the command below:
ssh -R 7869:localhost:7869 username@serverhost
where username is your user account on the server and serverhost is hostname or server IP address.

NOTE: you'd have ssh client running with the command above each time you want to debug through SSH.
NOTE: you may want to enable compression by adding -C argument to ssh.
NOTE: If you need an ssh client and/or server (daemon) for Windows please take a look here:

Remote PHP Debugging with Router on the network

When PHP Debugger and PHP IDE are running on different networks, you need either establish port forwarding on the NAT router or run ssh with reverse tunnel (a kind of data channel). If you prefer to use NAT forwarding, please locate the device through which your development machine is connected to the network. It's IP address is shown in the client outbound IP line in the Wizard results, then open the device configuration panel, and proceed according to the device's manual. Usually the feature is referred to as "NAT port forwarding" and lists 3 columns: inbound port number, target machine, and target port number. Sometimes it also let you set udp or tcp protocol. What you need is: inbound port = target port = 7869 (or whatever port you configured in the debugger settings), target host is the IP address of your development machine, protocol should be tcp.

Below is an Example of Port Forwarding setup on a typical router: PHP Debugger Remote Port Forwarding
With the release of PhpED 5.9.5 NuSphere PHP IDE can automatically setup remote debugging even if there is a router present on the network, as long as this router supports UPnP. In this case UpnP will be used by PhpED to automatically open ports for communications with for PHP Debugger.

The following example demonstrates the work of Project Wizard PHP Debugger Remote Automatic
When you select the option Router Supports UpNP port management, PhpED uses UpNP to open the communications with PHP Debugger and you don't need to setup Port Forwarding. PHP Debugger Remote Check


For UpNP to work:
  • Your router should support UPnP (most of newer routers do)
  • There are no additional requirements for Vista or Windows 7 OS. If you are running Windows XP you need to install UPnP.
    • Control Panel -> Add Remove Programs -> Add Remove Windows Components (button on the leftmost panel) -> Networking Services -> UPnP User Interface.
    • After this you should see an item called Internet Gateway in My Network -> Properties
If you encounterd a problem, please check related troubleshooting instructions here:


<Run debug sessionSet project mapping for debugging>
Last updated: Wed, 02 Feb 2011