Install ‘XHProf’ PHP extension for XAMPP on linux

In one of my previous posts I wrote about how we install 'xdebug' PHP extension for XAMMP on linux. So in the same spirit we look at XHProf which is a function-level hierarchical profiler for PHP.

For the people who have default PHP install, it's generally very easy to install 'XHProf' by doing

CODE:
  1. [root@amit ~]# pecl install xhprof-beta

as it is a PECL package.

But for those who run XAMMP the procedure is slightly longer but most of the installation procedure is same as http://mirror.facebook.net/facebook/xhprof/doc.html#installation . Of course there are a few quirks and that is what this post is about.

  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 'XHProf' source from http://pecl.php.net/get/xhprof, uncompress it in a suitable directory, cd to that directory and go to the 'extension' directory.
  3. Now run phpize
    CODE:
    1. [amit@amit ~/xhprof-0.9.2/extension]$ /opt/lampp/bin/phpize

  4. Configure the extension
    CODE:
    1. [amit@amit ~/xhprof-0.9.2/extension]$ ./configure --with-php-config=/opt/lampp/bin/php-config

  5. Run 'make' to compile the xhprof.so
    CODE:
    1. [amit@amit ~/xhprof-0.9.2/extension]$ make

  6. Run 'make install' so that xhprof.so file will be copied to PHP's extensions directory (you may need root privileges for this)
    CODE:
    1. [root@amit /home/amit/xhprof-0.9.2/extension]# make install

  7. After that edit php.ini file and add
    CODE:
    1. extension=xhprof.so

  8. Lastly restart XAMPP's apache server and check phpinfo for 'XHProf' extension.

I can't think of what can possibly go wrong with the above setup instructions but if it does, please put in a comment and I will 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'

3 Responses to Install ‘XHProf’ PHP extension for XAMPP on linux

  1. The Little Pirate April 23, 2010 at 8:25 pm #

    Hello,
    Thanks for the tutorial.

    When I tried to install it on my Fedora 12, I got an error that no stable package is available for xhprof as it is in beta stage

    It should be

    pecl install xhprof-beta

    • Amit Badkas April 26, 2010 at 8:50 am #

      Thanks for correction, I have updated the post accordingly.

  2. The Little Pirate January 3, 2011 at 11:53 am #

    XHProf doesn't work when installed on 64-bit systems.

    Before ./configure ,

    CFLAGS="-arch x86_64 -arch i386"

    should be run if installing on 64-bit architecture.

Leave a Reply