The Xdebug extension helps you debugging your script by providing a lot of valuable debug information. The debug information that Xdebug can provide includes the following:

  • stack traces and function traces in error messages with:
    • full parameter display for user defined functions
    • function name, file name and line indications
    • support for member functions
  • memory allocation
  • protection for infinite recursions

Xdebug also provides:

  • profiling information for PHP scripts
  • code coverage analysis
  • capabilities to debug your scripts interactively with a debug client

Information about Xdebug in Russian is available at

Xdebug can be installed in a few different ways – by downloading the binaries from the site, compiling the source, or via PECL:

sudo pecl install xdebug

Some days, I just prefer to download compile the source, as it gives me more of an understanding of what is being installed and where, and this is one of those days:

cd ~/
mkdir xdebug
cd xdebug
tar -zxvf xdebug-2.0.3.tgz
cd xdebug-2.0.3

The packages phpize and php-config are required to install Xdebug, and can be obtained by installing the relevant PHP development packages:

sudo apt-get install php4-dev


sudo apt-get install php5-dev

depending on the PHP version installed. After unzipping the Xdebug source, I ran


which output:

PHP Api Version: 20041225
Zend Module Api No: 20060613
Zend Extension Api No: 220060519

I then checked this against the table at to see if my PHP version (5.2.3) was compatible with Xdebug – it matched up to the table’s 5.2.x PHP version row, so I went ahead and installed:

./configure --enable-xdebug --with-php-config=/usr/bin/php-config

which created a file in the modules subdirectory. This file needs to be copied (or moved) to the PHP Extension directory, which on my system is in /usr/lib/php5/20060613/. An easy way to find the PHP extension directory is to run:


ok, so I copied the to the extension directory:

sudo cp modules/ /usr/lib/php5/20060613/

So far so good. Now PHP needs to be told about the extension, and to load it. This can be done by adding


to the php.ini file. However, on my Ubuntu system, the PHP extensions are activated by adding an .ini file to the/etc/php5/apache2/conf.d directory, for each extension installed. The .ini file is the extension_name.ini, so I created a file called xdebug.ini:

cd /etc/php5/apache2/conf.d
gksu gedit xdebug.ini

which for now, contains a single line:


After restarting the Apache server

sudo /etc/init.d/apache2 restart

I created a file called test.php in my Web Root directory, containing a call to the phpinfo() function:


and pointed my browser to http://localhost/test.php. Just before the “PHP Credits” section, is a small box containing information on Zend – and now, with a successful Xdebug installation, additional information on Xdebug:

The same information can be found by opening a Terminal and running

php -m

to output the loaded modules, and towards the end of the output, you should see

[Zend Modules]

alternatively, run

php -i | grep Xdebug

and if Xdebug has been installed successfully, you should see

with Xdebug v2.0.3, Copyright (c) 2002-2007, by Derick Rethans

Now, Xdebug needs to be enabled before any scripts can be debugged! So, in the php.ini file (or in my case, the newly created /etc/php5/apache2/conf.d/xdebug.ini file) I added the lines:


and restarted Apache again:

sudo /etc/init.d/apache2 restart


php -i | grep xdebug

in the Terminal, or using the test.php file containing phpinfo() shows that the new settings are being used, and Xdebug is active and running.

Post By Editor (2,827 Posts)

Website: →