Categories
Server

Install Xdebug on Linux Debian

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

Install them by running:

[code lang=”bash”]
apt-get update
apt-get install php5-dev php-pear make
[/code]

Then to install xdebug type:

[code lang=”bash”]
pecl install xdebug
[/code]

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

[code lang=”bash”]
find / -name “xdebug.so”
[/code]

Copy the location of xdebug.so.

Start editing a new file like this:

[code lang=”bash”]
nano /etc/php5/conf.d/xdebug.ini
[/code]

Enter your configuration, usually something like this:

[code lang=”bash”]
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
[/code]

Now restart apache2 by running

[code lang=”bash”]
/etc/init.d/apache2 restart
[/code]

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

[code lang=”php”]
phpinfo();
[/code]

Also in terminal you can do this:

[code lang=”bash”]
php -i | grep xdebug
[/code]

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