Install Xdebug on Linux Debian

First you need the follow packages installed:
* php5-dev
* php-pear
* make

Install them by running:

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

Then to install xdebug type:

pecl install xdebug

Now, DON’T add anything to php.ini but do this instead:

find / -name "xdebug.so"

Copy the location of xdebug.so.

Start editing a new file like this:

nano /etc/php5/conf.d/xdebug.ini

Enter your configuration, usually something like this:

zend_extension="LOCATION OF XDEBUG.SO ABOVE"

[debug]
xdebug.remote_enable=1
xdebug.remote_host=YOUR IP ADDRESS
xdebug.remote_port=9000
xdebug.remote_mode="req"
xdebug.idekey="YOUR IDE KEY"
xdebug.remote_autostart=0
xdebug.remote_handler="dbgp"
xdebug.remote_connect_back=0
xdebug.extended_info=1
xdebug.remote_log=/var/log/xdebug.remote_log.log

Now restart apache2 by running

/etc/init.d/apache2 restart

You can see if your xdebug is loaded in PHP by looking after xdebug in this output:

Also in terminal you can do this:

php -i | grep xdebug

Now to start a debug session your go to your site and append query string like this:
?XDEBUG_SESSION_START=YOUR_IDE_KEY

And to end a debug session you do this:
?XDEBUG_SESSION_STOP=YOUR_IDE_KEY

Read more about XDEBUG here.

Leave a Reply

Your email address will not be published. Required fields are marked *