Wednesday, April 17, 2013

Installing XDebug on Ubuntu 12.04

mkdir ~/opt && cd ~/opt
wget http://xdebug.org/files/xdebug-2.2.2.tgz
tar -xzvf xdebug-2.2.2.tgz && cd xdebug-2.2.2/
phpize
auto-apt run ./configure
make
sudo checkinstall
sudo nano /etc/php5/mods-available/xdebug.ini
sudo php5enmod xdebug
php -i | grep xdebug

Explanation

  1. Create directory opt inside the home directory and change to created directory. Change directory name and location as needed
  2. Get the latest version of Xdebug. Adjust URL to point to the latest or desired Xdebug version
  3. Prepare the build environment for a PHP extension. See phpize manual.
  4. Use auto-apt just in case there are missing dependencies. Not likely to happen in this case.
  5. Build extension
  6. Create and install deb package. For details see Checkinstall wiki.
    1. The package documentation directory ./doc-pak does not exist.
      1. Should I create a default set of package docs?  [y]: 
      2. Type y
    2. Please write a description for the package.
      1. End your description with an empty line or EOF.
      2. Enter Xdebug 2.2.2 or whatever might be suitable
    3. This package will be built according to these values:
      1. Options 0 to 13 listed
      2. Enter a number to change any of them or press ENTER to continue:
      3. Make changes as needed
  7. Create extension configuration file. For details see Xdebug Documentation.
  8. Enable extension
  9. Check if extension is installed and configured

Basic extension configuration

zend_extension=/usr/lib/php5/20100525/xdebug.so

Prerequests

See Compiling Software wiki entry. Aside from basics php5-dev package must be installed on the system.

5 comments:

  1. Or you can just use:

    sudo pecl install xdebug

    for the same effect.

    ReplyDelete
    Replies
    1. Case you need to install it on a single machine it does not make a difference. If you have to install it on several machines creating deb package is a way to go no doubt.

      Delete
  2. zend_extension=/usr/lib/php5/20100525/xdebug.so

    i apply the same steps but i can not find the 20100525 folder for zend_extension ... can u help me ?

    ReplyDelete
    Replies
    1. Check output of phpize. It should look like:
      $ phpize
      Configuring for:
      PHP Api Version: 20100412
      Zend Module Api No: 20100525
      Zend Extension Api No: 220100525

      Zend Module Api No should correspond to folder name in which xdebug.so is located.

      You could also list content of folder /usr/lib/php5 and find desired folder name.
      ls /usr/lib/php5

      Finally you could use command locate.
      locate xdebug.so You might need to run sudo updateddb before running locate command.

      Delete
  3. This comment has been removed by the author.

    ReplyDelete