You are here: Home / Debian GNU/Linux / Servers / PHP / Install the XDebug PHP extension on Debian

Install the XDebug PHP extension on Debian

by Pierre-Yves Landuré last modified Nov 11, 2017 09:32

XDebug is a powerfull debug tool for PHP. It add traces to error messages and step by step debugging.

This how-to is tested on:

  • Debian 6.0 Squeeze
  • Debian 7.0 Wheezy
  • Ubuntu 10.04 Lucid Lynx
  • Ubuntu 10.10 Maverick Meercat
  • Ubuntu 11.04 Natty Narwal

Prerequisites

This howto needs :

Installation from Debian repository

Install the software:

command apt-get -y install php5-xdebug

Reload the configuration:

test -e '/etc/init.d/php5-fpm' && command service 'php5-fpm' 'restart'
test -e '/etc/init.d/apache2' && command service 'apache2' 'force-reload'

Manual installation

If the Debian package is not available, install the extension manually.

Detect PHP extension configuration path:

MODS_CONF_PATH='/etc/php5/conf.d'
test -d '/etc/php5/mods-available' \
  && MODS_CONF_PATH='/etc/php5/mods-available'

Environment preparation

Install the needed software:

command apt-get install php5-dev make php-pear

Update PEAR:

command pear channel-update pear.php.net
command pear upgrade PEAR

Update PECL:

command pecl channel-update pecl.php.net
command pecl upgrade

Software installation

Install the extension:

command pecl install 'xdebug'

Detect the extension file path:

XDEBUG_SO="$(command find '/usr/lib/php5/' -name 'xdebug.so' \
| command head -n 1)"

Enable the extension:

echo "; configuration for php XDebug module
; priority=20
zend_extension=${XDEBUG_SO}" > "${MODS_CONF_PATH}/xdebug.ini"
test -n "$(command -v php5enmod)" && command php5enmod 'xdebug'

Reload the configuration:

test -e '/etc/init.d/php5-fpm' && command service 'php5-fpm' 'restart'
test -e '/etc/init.d/apache2' && command service 'apache2' 'force-reload'

Finalization

The manual installation recommends:

Thanks