Home > Web Development > Remote Debugging With PHPEd 5 Via PuTTY

Remote Debugging With PHPEd 5 Via PuTTY

February 13th, 2009


I started using PHP back when it was called PHP/FI. Before that, I made simple desktop applications using Visual Basic and REALbasic. So, I was used to having a step-by-step debugger available to diagnose problems in my code. At the time, I was unable to find any IDE for PHP which offered the same functionality.

Enter PHPEd. The PHPEd IDE offers a remote debugger for your PHP projects. The remote debugger is installed on your web server as a PHP module, and sends the debugging information back to your development computer where PHPEd is running. Because of this, you can debug your code in the environment where it will be living, with the same database, permissions, and http server.

The setup for remote debugging is not difficult, but I think this step-by-step article will help anyone who is using the same setup as I am. Just to be clear, that setup is:

  • PHPEd 5.0
  • Rackspace Hosted: RedHat Enterprise Linux 4 ES
  • PHP 5.2.3
  • PuTTY 0.60

Setting Up Remote Debugging

  1. Install PHPEd. If you do not already have PHPEd, you can download a trial at http://www.nusphere.com. Choose Complete Installation to ensure that you have all features.
  2. Download PuTTY if you do not already have it. PuTTY is a free SSH/Telnet client which can be found at http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html.
  3. You’ll also need an FTP client to move the PHPEd debugger (named DBG) to your web server. I recommend the free FileZilla, available at http://filezilla.sourceforge.net.
  4. You will need to find the appropriate debugger module, installed along with PHPEd, and move it to your web server. Here’s how:
    1. Open the PHPEd program directory \ debugger \ server \ Linux:
      C:\Program Files\nusphere\phped\debugger\server\Linux
    2. Look for the file named: dbg-3.1.12-Linux.tar.gz
    3. Transfer dbg-3.1.12-Linux.tar.gz to your web server using an FTP client, like FileZilla. It doesn’t matter where you put the file on your web server, because we will later extract the file, and move its contents elsewhere. So, you can simply FTP the file into your home folder on the web server, if you like. For this example, we will FTP the file to myfakeserver.com into directory: /home/nate
    4. Use PuTTY to establish an SSH connection to your web server.
    5. For this example, I will login to my web server as nate.
    6. For some of the following steps, you may need to be the root user. So, change to the root user.
    7. Extract the files from the dbg-3.1.12-Linux.tar.gz archive. In this case, the tar command does the follwing:
      • -v Use verbose output. (Show me what you’re doing!)
      • -z Use GZip to uncompress the archive.
      • -x Extract the archive.
      • -f Extract this file.
      tar -vzxf dbg-3.1.12-Linux.tar.gz
    8. After the files are done being extracted, the dbg-3.1.12-Linux folder will appear. Inside this folder are all of the DBG (debugger) modules for Linux. We only need one of them, specifically the one titled dbg.so-5.2.x located in dbg-3.1.12-Linux/x86/. You should move this module to your PHP modules folder.
      mv /home/nate/dbg-3.1.12-Linux/x86/dbg.so-5.2.x /usr/lib/php/modules/

      Please note, your PHP modules directory may be different. To find the path to your PHP modules folder, oppen your /etc/php.ini file and look at the extension_dir variable.

  5. You will need to modify your php.ini configuration file. Here’s how:
    1. Use a text editor, like nano or pico, to edit your php.ini file.
      nano /etc/php.ini
    2. Find the Dynamic Extensions section of the php.ini file. Add the following line to that section:
    3. At the end of the php.ini file, we will need to configure the DBG debugger. Add this code to the bottom of the php.ini file:
      debugger.ports=7869, 10000/16

      We are telling the debugger to allow a connection from localhost only, and listen for that connection on port 7869.

    4. Save the php.ini file, and exit the text editor. For nano and pico:
      Save Modified Buffer: Y
      File to write: /etc/php.ini
  6. You will need to restart the Apache web server for the above changes to take effect.
    /usr/sbin/apachectl restart
  7. You will need to open PHPed and configure the communication settings for the remote debugger.

    1. Open PHPEd on your development computer.
    2. Open the Tools menu and choose Settings.
    3. In the Tools section select Debugger.
      1. Check the box labeled: Use Custom Port and Host (SSH Tunneling).
      2. For Port enter 7869.
      3. For Debugger Host enter localhost.
      4. Click OK.
  8. You will need to configure your project to use the remote debugger.

    1. Still in PHPEd on your development computer…
    2. Right-click on your project and choose Properties.
    3. For this example, we’ll assume the following:
      • Your project’s root folder, on your development computer, is
      • Your project is published to a folder on the web server where it is served by Apache. That publishing folder is:
      • Your project contains at least one file, index.php, and that file is stored locally in:
      • That same file is published remotely in:
      • You access your project in a web browser at the following URL:
    4. In Project Properties, look at the Mapping section of the Properties tab.

      1. Choose HTTP Mode (3rd Party WEB Server) in the Run Mode popup menu.
      2. Enter http://www.myfakeproject.com in the Root URL field.
      3. Enter /home/myfakeproject/htdocs in the Remote Root Directory field.
  9. You will need to configure PuTTY to forward SSH traffic from the Debugger.

    1. Open PuTTY on your development computer.
    2. Create a new Session to be used with the PHPEd debugger.
      1. In the Host Name (or IP Address) field enter the host name for your web server.
      2. In the Saved Sessions field enter a name for your session:
        MyFakeProject.Com Debugger
      3. In the Category panel select:
        Connection » SSH » Tunnels

        1. In the Source Port field enter: 7869
        2. In the Destination field enter: localhost:7869
        3. Select the Remote radio button.
        4. Click Add.
      4. In the Category panel select:
      5. Click Save.
  10. Before you start debugging your code in PHPEd, you will need to connect to this session in PuTTY. By doing so, you will forward all of your debugger traffic via SSH.
  11. Now that everything is set up, debugging in PHPEd is simple! Simply open the root file for your web site, index.php, and click the Run in Debugger F9 button. If you don’t have the debugger toolbar, then simply open the Run menu and choose Run in Debugger F9.

Nate Smith Web Development , , , , , ,

  1. CoreanPeople
    | #1

    Thank you. it was very helpful for me to solve the problem.
    You are excellent than their NuSphere’s help document…

  1. No trackbacks yet.