XDebug not working Ubuntu PHP 5.6

XDebug not working Ubuntu PHP 5.6, 10.0 out of 10 based on 1 rating
VN:F [1.9.22_1171]
Rating: 10.0/10 (1 vote cast)

I faced the issue that Ubuntu with PHP 5.6 didn’t load xDebug.
I installed xDebug by entering:

sudo apt-get install php5-xdebug

First issue that I encountered was that the xdebug.ini was not added to apache.
Enter:

find / -name ‘xdebug.so’ 2> /dev/null

xdebug.ini:

[xdebug]
zend_extension = “/usr/lib/php5/20121212+lfs/xdebug.so”
xdebug.remote_enable=on
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=localhost
xdebug.remote_port=9000

zend_extension = “/usr/lib/php5/20121212+lfs/xdebug.so” replace by the output of:

find / -name ‘xdebug.so’ 2> /dev/null

Place xdebug.ini in:

/etc/php/5.6/apache2/
/etc/php/5.6/mods-available/

You could also try:

php5enmod xdebug

Anyway it was not loading even if everything is ok.
So I researched further and found out why it’s not loading. In order to display why it’s not loading just add:

display_startup_errors = On

In your php.ini.

After that check /var/log/apache2/error_log:

Xdebug requires Zend Engine API version 220121212.
The Zend Engine API version 220131226 which is installed, is newer.
Contact Derick Rethans at http://xdebug.org/docs/faq#api for a later version of Xdebug.

So I guess we’ve to compile our own:

wget https://xdebug.org/files/xdebug-2.5.0.tgz
tar xfvz xdebug-2.5.0.tgz
cd xdebug-2.5.0
phpize

Configuring for:
PHP Api Version:         20121113
Zend Module Api No:      20121212
Zend Extension Api No:   220121212

./configure
make

Libraries have been installed in:
/var/tmp/xdebug-2.5.0/modules

make install

Installing shared extensions:     /usr/lib/php5/20121212+lfs/

That didn’t work either. PHP version used by phpize is:
20121212 not 220131226

Uninstalled php5-dev and installed matching php5.6-dev:

sudo apt-get install php5.6-dev

Now looks good:

phpize

Configuring for:
PHP Api Version:         20131106
Zend Module Api No:      20131226
Zend Extension Api No:   220131226

make clean
make
make install

Installing shared extensions:     /usr/lib/php/20131226/

adjust path in /etc/php/5.6/mods-available/xdebug.ini

and great, it’s finally working:
php -v
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
    with Xdebug v2.5.0, Copyright (c) 2002-2016, by Derick Rethans

FINALLY got it working 🙂

This entry was posted in Linux, PHP. Bookmark the permalink.

Leave a Reply

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