Howto install Xdebug
Quick guide to installing Xdebug on OS X with php5.2 (installed using macports) and apache2 (also installed using macports).
- Open up a terminal (personally I like iTerm more than Apple’s Terminal, but any terminal application will do fine). The default terminal program can be found in Applications->Utilities->Terminal.app.
- Type the following: sudo pecl install xdebug-beta. This should download, compile and install the xdebug extension
- Add the following line to your php.ini: zend_extension=”/opt/local/lib/php/extensions/no-debug-non-zts-20060613/xdebug.so”
Just a few sidenotes:
- I could not set the php.ini path in pecl.
Somehow sudo pecl config-set php_ini /opt/local/etc/php.ini gave me “config-set (php_ini, /opt/local/etc/php.ini, user) failed, channel pecl.php.net” So I manually added the extension path (point 3) to the php.ini file.
- My php.ini file could be found here: /opt/local/etc/php.ini
- Don’t forget to include the full path to the xdebug extension. Do not use the extension_dir option in the php.ini as this does not seem to work. I learned this the hard way when I could not get the extension to load and saw these error messages appearing in the Apache2 log: Failed loading xdebug.so: (null)
- In order to check if the extension was succesfully loaded, create a file with the contents here below:
<?php
phpinfo();
?>
Save the file as info.php in your webdirectory and navigate to this file using the browser. Now you should see the phpinfo overview and Xdebug should be part of it. If you don’t see Xdebug, then check your Apache error logs (path to my apache logs: /opt/local/apache2/logs/) to see what went wrong.

June 15th, 2009 at 9:51 pm
I’ve had luck getting xdebug working without pecl. I am using a Macports Apache setup with php5-xdebug. I’ve got directions to the debugger client and callgrind viewer in my post too.
Kevin
June 15th, 2009 at 9:54 pm
Forgot to give you a link:
http://littleblackhat.com/blog/?p=12