Sharing technology, ideas, insights!
Call: +91 710 466 0336         Email: hello@sanisoft.com

Blog

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
  4. Configure the extension
  5. Run ‘make’ to get the compiled xdebug.so
  6. Copy the xdebug.so file to PHP’s extensions directory (you may need root privileges for this)
  7. After that edit php.ini file and add
  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 the Author

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

22 comments

  1. 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. 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. 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. 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.

  5. 🙂 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.

  6. 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”

  7. 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: ELFCLASS64XAMPP: 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.

  8. 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!!!

  9. 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.

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

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

  11. 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?

  12. 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

  13. 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.

  14. Pingback: Töre Çağrı Uyar » Blog Archive » 32bit Xdebug on 32bit LAMPP on 64bit Linux (WTF!?)

  15. Pingback: Install ‘XHProf’ PHP extension for XAMPP on linux at SANIsoft – PHP for E Biz

  16. Pingback: Sevka IT blog » Архив блога » XDebug + PDT на LAMPP (XAMPP)

  17. Hey, i just wanted to drop a line. Great howto! I ran into problems as I am using 64 bit Linux (i think most peeps are these days). This is how I got it to successfully compile on Debian variant of Linux (ie Debian, Ubuntu, LinuxMint, etc…)

    Before step 4:

    Step 3.5: sudo apt-get install libc6-dev-i386

    Step 4: ./configure CC='cc -m32' CXX='g++ -m32' --x-libraries=/usr/lib --target=i686-pc-linux --enable-xdebug --with-php-config=/opt/lampp/bin/php-config

    This solved the 64bit compilation error, and allowed xampp to restart correctly. It would be great if you could update the article to include this step to save readers the time for searching (this article is one of, if not the top hit, on Google). Thanks again for the great howto.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.