Installing Xdebug on CentOS

Here are exact steps to follow on CentOs:

1. Install PHP’s devel package for PHP commands execution

yum install php-devel

2. Make sure you also have php-paer package installed:

yum install php-pear

3. Next install GCC and GCC C++ compilers to compile Xdebug extension yourself.

yum install gcc gcc-c++ autoconf automake

4. Compile Xdebug

pecl install Xdebug

5. Find the php.ini file using

locate php.ini

6. Add the following line to php.ini

[xdebug]
zend_extension="/usr/lib64/php/modules/xdebug.so"
xdebug.remote_enable = 1

7. Restart Apache

service httpd restart

8. Test if it works

Create test.php with the following code:

<?php phpinfo() ?>

and check if you have the following output:

Summary: You installed XDebug by Derick Rethans as Zend_Extension. Installing XDebug as Zend Extension is very important because that way you can Debug step by step in different IDEs.

If you like to compile the xdebug.so object file yourself in order to get the latest version of xdebug.so here are the steps to follow:

  • Download latest xdebug-X.Y.Z.tgz from xdebug web site

  • Unpack the downloaded file with tar -xvzf xdebug-X.Y.Z.tgz to some test folder

  • Run: cd xdebug-X.Y.Z

  • Run: phpize (to prepare the environment)

  • Run: ./configure

  • Run: make (now you have xdebug.so created;)

  • Copy xdebug.so to your modules file (in my case /usr/lib64/php/modules)

  • Make sure you have the following in php.ini

zend_extension = /usr/lib64/php/modules/xdebug.so
  • Make sure you have the execute permission for the xdebug.so file
chmod +x /usr/lib64/php/modules/xdebug.so
  • Restart the webserver

PS. Please note with the release of PHP 6.0 you will probable see Zend Engine 3 in the last image.

tags: centos - xdebug & category: php