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
-
[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.
- 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.
- 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.
- Now run phpize
CODE:
-
[amit@amit ~/xhprof-0.9.2/extension]$ /opt/lampp/bin/phpize
-
- Configure the extension
CODE:
-
[amit@amit ~/xhprof-0.9.2/extension]$ ./configure --with-php-config=/opt/lampp/bin/php-config
-
- Run 'make' to compile the xhprof.so
CODE:
-
[amit@amit ~/xhprof-0.9.2/extension]$ make
-
- Run 'make install' so that xhprof.so file will be copied to PHP's extensions directory (you may need root privileges for this)
CODE:
-
[root@amit /home/amit/xhprof-0.9.2/extension]# make install
-
- After that edit php.ini file and add
CODE:
-
extension=xhprof.so
-
- 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.
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
Thanks for correction, I have updated the post accordingly.
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.