PHP Remote Debugging with XDebug and NetBeans
Although some of these instructions are specific to Debian Linux (and more specifically, for MindTouch 2009 Enterprise VM), hopefully these steps will get you up and running with PHP debugging (and not the kind where you litter your code with print statements, or take a var_dump() all over your code…).
No, this is for the kind of debugging where you can set breakpoints, watch variables, look at the stack trace, and modify your code on the fly! Hooray for that!
So, here’s what you need to do:
- Log into your MindTouch 2009 Enterprise VM as root (yes, root can be dangerous, but I trust you)
- You will need some PHP development prerequisites, like the ability to use Make and Pecl. First, we’ll grab all the essentials for building from source (the # is the command-line prompt):
# apt-get install build-essential
- We also need the php5 development tools, which includes Pecl:
# apt-get install php5-dev
- Next, we can use Pecl to install XDebug:
# pecl install xdebug
- Now you should have XDebug installed, but not configured. Let’s do that. We need to add a few lines to ALL of our php.ini files to enable and configure remote debugging:
# nano /etc/php5/cli/php.ini
- This will open php.ini in the terminal editor. Add these lines to the file, with these caveats:
- The path to xdebug.so must exist! Check that it’s there
- The value for xdebug.remote_host must be your host IP address (not the vm’s IP address!). If you don’t have a static IP, you may have to update this and restart the web server each time you fire up the VM!
- Make sure the xdebug.remote_port port is open in both your host and the VM (it probably is by default)
- You should ignore any prompts to add “extension=xdebug.so” to php.ini – this will cause problems
zend_extension="/usr/lib/php5/20060613+lfs/xdebug.so" xdebug.remote_enable=1 xdebug.remote_handler=dbgp xdebug.remote_mode=req xdebug.remote_host=192.168.1.72 xdebug.remote_port=9000
- Use Ctrl-O, Enter to write the file, then Ctrl-X to exit
- Repeat steps 5, 6 and 7 for /etc/php5/apache2/php.ini
- Restart Apache
# /etc/init.d/apache2 restart
- Restart MindTouch
# /etc/init.d/dekiwiki restart
- Check to see if XDebug is installed correctly. Run the following command, which lists all PHP modules. You should see XDebug twice; once under [PHP Modules], and once under [Zend Modules]
- Make sure you have your Samba share set up so you can access it from your host filesystem
- In NetBeans, create a new project from existing sources, and point it to \drive\var\www\dekiwiki”>\drive\var\www\dekiwiki”>\drive\var\www\dekiwiki”>\\<VM_IP_Address>\drive\var\www\dekiwiki
- Specify index.php as the home page
- Set a breakpoint somewhere in \includes\Article.php
- By default, NetBeans will automatically stop on the first line of the home page (for stepping through). If you want it to only stop if it hits a breakpoint, go to Tools/Options, then select the PHP tab, and uncheck “Stop at first line”:

- Click the Debug icon in the toolbar and weep with joy at the beauty of real debugging!
Of course, you may encounter problems along the way… if you do, the following resources may be of help:
- Debugging PHP with NetBeans
- Configure XDebug on Linux
- More details about what you can do with debugging
- The XDebug Home Page
Happy Bug Fixing!
Leave a comment
Recent Posts
- Facebook IPO
- The Ballad of Tim Toady
- The Little Schemer
- Newsflash: Mom leaves tech job at 5p.m.
- Flashback!
- I <negative_emotion> Windows 8!
- Prefix vs. Postfix Increment and Decrement Operators in C++
- Corporate videos: viral boon or epic fail?
- Recruitin’ Time!
- Reference vs. pointer parameters in C++
- The IE8 "hover" Bug: The Most Awesome IE Bug Ever?
- When is perfect perfect enough?
- SOPA/PIPA: Anti-Censorship Protest or Techies Revenge?
- A Decade of Fairway
- Handling Session Timeout Gracefully
- Generating Software Diagrams
- The Audacity of Nope
- The Origins of Culture
- Scrum Overview in Prezi – not another boring slideshow
- Numbers don’t lie: LinkedIn Statistics
- What is your favorite software development tool?
- Best Practices for Selecting Onshore, Nearshore or Offshore Information Technology Outsourcing (ITO) Providers
- Sign of the Times
- Advantages and Risks of Offshoring, Nearshoring or Onshoring
- Does Outsourcing Mean Offshoring?
- Too little, too late?
- New Favorite Lunch Spot
- Why should I care about functions as first-class citizens?
- PHP Remote Debugging with XDebug and NetBeans
- Installing SubText with Web PI
- ROI Primer
- Learn Domain-Driven Design
- Learn Behavior-Driven Development
- Mario Kart Tournament
- F# in 90 Seconds
- Website Vulnerabilities
- Scrum Overview
- Language Club
- Top 12 Favorite Podcasts Ever…
- Fairway Dart Tournament
- Learn Lean Software Development and Kanban Systems
- Android – Eclipse Quick Start
- Learn Functional Programming
- Backup & Restore Strategy
- Smartphone Screens – Another Wireless Variable
- Wireless Application Market
- Head First AOP





