Installation and configuration of Xhprof for Drupal in Centos/Ubuntu

XHProf is a function-level hierarchical profiler for PHP and has a simple HTML based navigational interface. The raw data collection component is implemented in C (as a PHP extension). The reporting/UI layer is all in PHP.

Common Terms:

Inclusive Time includes the time spent in the function itself and in all the descendant functions;

Exclusive Time only measures time spent in the function itself, without including the descendant calls.

Install the PHP5 module:

graphviz Installation it's used for Displaying the execution path in a kind
of flow chart between methods.

# for centos sudo yum install graphviz

# for ubuntu and debian sudo apt-get install graphviz

 

Install PECl on centos:

yum install php-pear

But get: No package Available

For Centos 5:

rpm -Uvh http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm; rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm;

For Centos 6:

rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm; rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm;

 

Install php -pear:

yum --enablerepo=remi,remi-php55 install php-pear

 

For Ubuntu OS:

sudo pear upgrade pear sudo pecl install -f xhprof

Add this to php.ini

extension=xhprof.so

Restart using this command

sudo /etc/init.d/apache2 restart

Install xhprof:

sudo pecl config-set preferred_state beta sudo pecl install xhprof cd /tmp wget http://pecl.php.net/get/xhprof-0.9.4.tgz tar zxf xhprof-0.9.4.tgz cd xhprof-0.9.4/extension phpize ./configure make sudo make install # for centos sudo touch /etc/php.d/xhprof.ini # for ubuntu and debian sudo touch /etc/php5/conf.d/xhprof.ini

 

Paste the below code in to xhprof.ini

[xhprof] extension=xhprof.so xhprof.output_dir="/tmp/xhprof"

 

Then restart the web server by below command

# for centos sudo /etc/init.d/httpd restart # for ubuntu and debian sudo /etc/init.d/apache2 restart

Install the supporting PHP code

git clone git://github.com/preinheimer/xhprof.git cd xhprof_lib/ cp config.sample.php config.php

Move xhprof

Move xhprof file from tmp folder to opt folder(It preserve xhprof file never delete when server restart)

mv xhprof-0.9.4 /opt


Create the alias for the xhprof at apache conf for the file location:
For Apache2:
 

cd /etc/apache2/sites-enabled/000-default.conf Alias /xhprof /opt/xhprof-0.9.2/xhprof_html

For Apache:

cd /etc/httpd/conf/httpd.conf Alias /xhprof /opt/xhprof-0.9.2/xhprof_html.

 

Put the entry on web interface(UI):

Save the configurations of xhprof file and alias in devel settings.
SITE_URL/admin/config/development/devel

Report

Category: