how to install xdebug on linux

chris (2008-02-24 19:53:34)
12651 views
1 replies
Installing PECL modules in the past was tricky, but to install a pecl extension now is much easier. Xdebug is no exception. On some distros, you might have to install a php-dev package to make this work. Once that's done, you can just use the pecl command to install new extensions like this:
chris@chris-laptop:~$ sudo pecl install xdebug
[sudo] password for chris:
downloading xdebug-2.0.2.tgz ...
Starting to download xdebug-2.0.2.tgz (279,621 bytes)
..................done: 279,621 bytes
65 source files, building
running: phpize
Configuring for:
PHP Api Version:         20041225
Zend Module Api No:      20060613
Zend Extension Api No:   220060519

At this point, you will see the same kinda output as you would expect to see from a ./configure; make; make install.

At the end of the process, you will see the installation complete with some recommended configuration changes required to get things started. This should look like the following:

Build process completed successfully
Installing '/usr/local/lib/php/extensions/no-debug-non-zts-20060613/xdebug.so'
install ok: channel://pecl.php.net/xdebug-2.0.2
configuration option "php_ini" is not set to php.ini location
You should add "extension=xdebug.so" to php.ini

At this point, you should open your php.ini file an add the line as suggested, but use the zend_extension directive as follows:

zend_extension = /usr/local/lib/php/extensions/no-debug-non-zts-20060613/xdebug.so

Of course you should check that the path matches what your installer output provides.

And then you just need to restart apache and you're done.

To check that your installation is working, try running the following code (which is similar to one of the test scripts on the xdebug site):

<?php
    function test(){
        echo "Called @ ".xdebug_call_file().
        ":".xdebug_call_line()." from".
        xdebug_call_function();
    }

    test();
?>

And then you can test this just by running it:

chris@chris-laptop:~/junk$ php -e xdebug.php 
Called @ /home/chris/junk/xdebug.php:8 from{main}chris@chris-laptop:~/junk$ 

You now have all the xdebug function calls working.

christo
comment
todd
2010-02-26 19:09:54

great article

I have to tell you! This article was the best and quickest way to get started with Xdebug.
Very well written, very concise.
Thanks!
-T
reply iconedit reply