HOWTO Install xdebug for PHP5 on Ubuntu Feisty

This article is incomplete and was first written in April 2007
for the BeezNest technical website (


Xdebug is an extension for PHP which allows you to track errors and warning in a much more detailed way than what you could get by adding debug messages into your code. However, installing it on a Linux system when there is no package might represent a little difficulty for the developer-only. This article is only meant to help save a few dozens of minutes from your time by providing the short list of what you need to do on an Ubuntu system to get it rolling.

Technical details

First, you don't need Xdebug if you don't have PHP. I assume you will be using PHP5, as it begins now to be the standard on all systems. If you don't have PHP running, first refer to to know how to install it. On an Ubuntu system, we first check if a package is available for Xdebug
apt-cache search xdebug
… not much for PHP5 anyway. The idea is that we will then use the second affordable option: install it with PEAR. The PEAR package for PHP offers a command-line tool to download-and-install extensions from the PEAR or PECL websites ( and, respectively). PECL is a bit more restrictive than PEAR, which also means that - in general - you will get more reliable and structured packages from PECL, but you will get more packages in total from PEAR. You can get information on Xdebug from the PECL website: or you can get installation information from the xdebug website: Anyway, we want to install the PEAR command-line tool:
sudo apt-get install php-pear
Then we can start using the pecl command-line script to look for the xdebug extension package
sudo pecl search xdebug
Now you can probably see that there are two versions available. The 1.3.2 and the 2.0.0 RC3 at the time of writing this article. The RC3 version is quite stable and offers considerable advantages, so you migh want to install this one. To do this, use the following command
sudo pecl install xdebug-beta
Now depending on what packaged are already installed on your Ubuntu system, you might end up with the following error message: Error: 'phpize' failed This is due to the missing command-line application "phpize" (as you could get from other messages). To install this one:
sudo apt-get install php5-dev
Now you can start again
sudo pecl install xdebug-beta
At the end of the process, you get the following message
install ok: channel://
You should add "" to your php.ini
And that's what we're going to do. Edit ''/etc/php5/apache2/php.ini'' and look for the section called ''Dynamic Extensions''. On the last line of this section, add the line
Now save the file, close it, and restart Apache
/etc/init.d/apache2 restart
That's it! Now you'll see an additional display (which can be quite long) each time you generate a warning or error message. This message tells you exactly how the script processes through until it gets to the error. If you want to change the way it works now, you'll have to find it by yourself on the xdebug website (, because this is out of scope here. Have fun!