Install ‘xdebug’ PHP extension for XAMPP on linux

In my previous post I wrote about how we install XAMMP in the home directory of a user. We often need to profile our code and often on a variety of setups, the answer of course is to use Xdebug.

Following is the procedure for installing PHP's 'xdebug' extension for XAMPP on linux (most of the installation procedure is same as http://www.xdebug.com/docs/install but there are a few quirks).

  1. First you have to install XAMPP development package (http://www.apachefriends.org/en/xampp-linux.html) for your XAMPP installation. This package provides the necessary source files needed to compile the extra stuff
  2. Download 'xdebug' source from http://www.xdebug.com/ , uncompress it in a suitable directory, cd to that directory.
  3. Now run phpize
    CODE:
    1. [amit@amit xdebug-2.0.0RC4]$ /opt/lampp/bin/phpize

  4. Configure the extension
    CODE:
    1. [amit@amit xdebug-2.0.0RC4]$ ./configure --enable-xdebug --with-php-config=/opt/lampp/bin/php-config

  5. Run 'make' to get the compiled xdebug.so
    CODE:
    1. [amit@amit xdebug-2.0.0RC4]$ make

  6. Copy the xdebug.so file to PHP's extensions directory (you may need root privileges for this)
    CODE:
    1. [root@amit xdebug-2.0.0RC4]# cp modules/xdebug.so /opt/lampp/lib/php/extensions

  7. After that edit php.ini file and add
    CODE:
    1. zend_extension=/opt/lampp/lib/php/extensions/xdebug.so

  8. Lastly restart XAMPP and check phpinfo for Xdebug extension

I can't think of what can possibly go wrong with the above setup instructions but if it does, put in a comment and I can try to help

About Amit Badkas

Amit Badkas is Zend certified PHP5 and Zend Framework engineer, and has been working in SANIsoft for past 9 years, his present designation is 'Technical Manager'

21 Responses to Install ‘xdebug’ PHP extension for XAMPP on linux

  1. shane July 5, 2007 at 3:57 pm #

    xdebug-2.0.0RC4 only works for xampp with php5 (for me)
    Has something to do with php header files.
    I think that atm you can only compile xdbug agains a single php version.

    Perhaps with some tweaking, symlinking etc, and a second xdebug config/compile it might be possible to have xdebug working for php4 and php5.

  2. patrick July 7, 2007 at 4:07 am #

    i ran into the same problem as shane, fixed it by downloading php sources (4.4.7) and extracting into the xampp include folder over the existing php folder. that gives you the correct version #s for phpize, and everything seems to work afterwards

  3. Jim July 19, 2007 at 3:17 am #

    I am using xdebug-2.0.0RC4 with xampp with php5 and followed the instructions except to avoid global alloc variable not found error I used zend_extensions_ts and phpinfo and php -m does not show xdebug. Any ideas?

  4. rahul October 1, 2007 at 5:32 pm #

    Nice

  5. Bhushan March 5, 2008 at 7:32 pm #

    Hi,

    I dowloaded php_xdebug-2.0.2-4.4.6.dll and want to run it with XAMPP (basic package) version 1.6.3a

    Another requirement is that I want to run XAMPP with PHP 4.

    I followed the instructions at the xdebug site and also here but when I tried to start XAMPP it didnt.

    Cannot implement Patrick's solution as I have made many changes to my PHP installation.

    Any other way out on this?

    Thanks in advance.

  6. Sloothword April 20, 2008 at 4:02 am #

    :-) Thanks. It worked fine for a Linux beginner. I had to install autoconf and do a few other tricks, but without this tutorial i would have been lost :-(
    I hope configuring eclipse to use Xdebug will work, too.

  7. Renaud June 27, 2008 at 12:23 pm #

    great instructions!
    i had to
    sudo apt-get install autoconf
    on Ubuntu, otherwise, you will get "Cannot find autoconf. Please check your autoconf installation and the $PHP_AUTOCONF"

  8. Francisco October 9, 2008 at 3:32 pm #

    hello,
    i've been using this, as well as some other tutorials i found explaining how to do this... with all pretty much saying the same thing. My problem is this: after copying xdebug.so to /opt/lampp/lib/php/extensions, editing my php.ini accordingly, and restarting my xampp install, i receive the following message:


    Starting XAMPP for Linux 1.6.8a...
    Failed loading /opt/lampp/lib/php/extensions/xdebug.so: /opt/lampp/lib/php/extensions/xdebug.so: wrong ELF class: ELFCLASS64
    XAMPP: Starting Apache with SSL (and PHP5)...
    XAMPP: Starting MySQL...
    XAMPP: Starting ProFTPD...
    XAMPP for Linux started.

    i am using Ubuntu Hardy (8.04) amd64, xampp 1.6.8a, and xdebug 2.0.3. if you have any tips on why i am getting this error, or could point me in the right direction towards a solution, i would be very grateful :) thank you for the post, and hopefully for your followup to this issue.

  9. Tarique Sani October 9, 2008 at 3:49 pm #

    http://www.google.co.in/search?q=wrong+ELF+class%3A+ELFCLASS64 4th or 5th link

    I did not know the answer to the problem till a few min ago :)

  10. Francisco October 9, 2008 at 4:15 pm #

    hey Tarique,
    thanks for your quick reply... i'm assuming you mean the Ubuntu forums link... I've read all of the pages on the first page of results from that query you posted (which i had already used as a google query :) ), but haven't found the solution just yet.

    i believe that what's happening is that my XAMPP stack is running at 32-bit, and my version of xdebug.so is being compiled as 64-bit since i'm running x86_64 ubuntu. this is causing the conflict.

    i would like to compile xdebug as 32-bit... do you know if there's a flag i can pass to ./configure or somewhere else to achieve this? thanks again!!!

  11. Francisco October 10, 2008 at 2:05 am #

    so, in the end, i just booted with the 32bit live cd of the same version of Ubuntu, compiled there, and copied the file over to my harddrive. now everything works.

  12. Nik November 3, 2008 at 9:22 pm #

    @Francisco any chance you could share your precompiled 32bit xdebug.so? Thanks.

    /@Tarique Sani could you send me Francisco email, please?/

  13. Francisco November 5, 2008 at 12:24 am #

    i'd be happy too... but i can't do it here :) if you give me an email address, i can send it to you.

    @Tarique - if you want, i can email to you and you can post here?

  14. Tarique Sani November 5, 2008 at 5:35 pm #

    @Francisco - as per his twitter think Nik solved the problem - you can post a URL in the comment anyways, will help someone else...

  15. Jonatas Esteves November 6, 2008 at 6:23 am #

    For those who need 32bit working builds of xdebug for Linux, MacOS X or Windows, ActiveState (the makers of the Komodo IDE) provide their pre-compiled binaries of xdebug they use in their IDE.
    Just go to their site:
    http://aspn.activestate.com/ASPN/Downloads/Komodo/RemoteDebugging
    and get one ;)
    The packages contain builds for all php versions.
    They always provide the lastest trunk build thoug. For the stable version (actualy 2.0.3) you'll still need to build your own binary.

    Hope that help! Jonatas

  16. movies November 6, 2008 at 10:00 pm #

    Thanks a lot. Great instructions

  17. tb October 4, 2009 at 9:17 pm #

    Greetings!
    I've been running into the ELFCLASS64 problem and can't figure out how pass a -m32 option to ./configure.

    Would anyone be willing to share one of your 32 bit binaries? ... or share a hint on how to compile with the 32 bit option? Thanks a bunch in advance.

  18. Tomas April 2, 2010 at 1:05 am #

    best howto i ever seen :)
    thx

Trackbacks/Pingbacks

  1. Töre Çağrı Uyar » Blog Archive » 32bit Xdebug on 32bit LAMPP on 64bit Linux (WTF!?) - January 13, 2010

    [...] Install ‘xdebug’ PHP extension for XAMPP on linux [...]

  2. Install ‘XHProf’ PHP extension for XAMPP on linux at SANIsoft – PHP for E Biz - February 15, 2010

    [...] one of my previous posts I wrote about how we install 'xdebug' PHP extension for XAMMP on linux. So in the same spirit we [...]

  3. Sevka IT blog » Архив блога » XDebug + PDT на LAMPP (XAMPP) - March 4, 2010

    [...] Install ‘xdebug’ PHP extension for XAMPP on linux [...]

Leave a Reply