Installing Xdebug for PHP 5 on Ubuntu "Feisty Fawn"

Xdebug is a PHP debugger with nice Eclipse integration. Here are some instructions for installing it (assuming you already have Apache 2 and PHP 5).

This article explains in more detail, but isn't Ubuntu-specific. It does detail Eclipse configuration for Xdebug in detail, though.

You need to be root to do the installation.

First off, install Xdebug. This isn't packaged for Ubuntu, so you need to do it with PECL. So install PECL if you don't have it:

apt-get install pecl

Use PECL to install Xdebug:

pecl install xdebug

Configure PHP 5 to use Xdebug by adding these lines to /etc/php5/apache2/php.ini (somewhere near where the other extension= lines are):

zend_extension=/usr/lib/php5/20060613+lfs/xdebug.so

[xdebug]
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_port=9000
xdebug.remote_host=127.0.0.1
xdebug.remote_log=/var/log/apache2/xdebug_remote.log

Note you need to use zend_extension= to load the extension, and you should use the absolute path to the module (.so file) to do this. Otherwise it fails.

Check using PHP info, e.g. add a file called phpinfo.php to your web root:

<?php phpinfo(); ?>

Then call it in your browser. Check that there is an Xdebug section displayed.

That's Xdebug installed. See the article linked at the start of this entry if you want to integrate with Eclipse.

Comments

Thank you...

Man, thank you for this post.
I was search for xdebug configuration. ;]

Question...

You wrote: "Note you need to use zend_extension= to load the extension, and you should use the absolute path to the module (.so file) to do this. Otherwise it fails."

So, what is the name of the extension? Where do I find it?

If you have a look in the

If you have a look in the sample config. in the post, you should see an example path (/usr/lib/php5/20060613+lfs/xdebug.so). I can't be definitive about where it's located, as the path to the extension (and in some cases, even the name of the file) depends on the version of Linux/PHP/Apache you're using. But it's likely to be called something like xdebug.so and be located in your PHP installation's extensions directory (look for the extension_dir setting in your php.ini file to work out what the latter is).