Centos6 install xhprof extension, centos6xhprof
Configure the yum Source
Append the epel and remi source of CentOS 6.5
# rpm -Uvh http:
//ftp.iij.ad.jp/pub/linux/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm
# rpm -Uvh http:
//rpms.famillecollet.com/enterprise/remi-release-6.rpm
Check the installed php package
# Yum list -- enablerepo = remi -- enablerepo = remi-php56 | grep php
Install php5.6
# Yum install -- enablerepo = remi -- enablerepo = remi-php56 php-opcache php-devel php-mbstring php-mcrypt php-mysqlnd php-phpunit-PHPUnit php-pecl-xdebug php-pecl -xhprof
View php version
# Php -- version or php-v
Install php-fpm
# Yum install -- enablerepo = remi -- enablerepo = remi-php56 php-fpm
The above is just preparation !!!
# Wget http://pecl.php.net/get/xhprof-0.9.4.tgz
# Tar zxvf xhprof-0.9.4.tgz
# Cd xhprof-0.9.4
# Whereis phpize
#/Usr/bin/phpize # location of the command obtained in the previous step
If the following error is reported:
Cannot find config. m4.
Make sure that you run '/usr/bin/phpize' in the top level source directory of the module
Then
Enter the extension directory in the current directory:
# Cd extension/
# Ls config. m4 php_xhprof.h tests xhprof. c
# PhpizeConfiguringfor: PHPApiVersion: 20100412 ZendModuleApiNo: 20100525 ZendExtensionApiNo: 220100525
Then compile and install:
# Whereis php-config # Find the location of php-config #. /configure -- with-php-config =/usr/bin/php-config #/usr/bin/php-config previous result # make & make install
If no error is reported, the installation is successful, and the extension is added to the php. ini file.
# Vim/etc/php. ini
Add a sentence to the file:
Extension = xhprof. so
Restart php-fpm to take effect
# Service php-fpm restart
The xhprof extension has been installed.
How to Use xhprof
Copy the file to the website directory and add the monitoring code to the statistics file. This step introduces the file
# mkdir -p /
Home/www/xhprof & cd/home/www/xhprof/
I used to download the xhprof-0.9.4 package in the tmp directory.
# cp -r /tmp/xhprof-0.9.4/xhprof_html/ ./
# cp -r /tmp/xhprof-0.9.4/examples/ ./
# Cp-r/tmp/xhprof-0.9.4/xhprof_lib/./# mkdir logs
Project usage (hitting ):
1. Start flag
Xhprof_enable ();
2. The included function body is also the function to be checked in the project.
Function ();
3. End mark
$ Data = xhprof_disable (); $ xhprof_root = "/home/wwwroot/xhprof"; include_once $ xhprof_root. "/xhprof_lib/utils/xhprof_lib.php"; include_once $ xhprof_root. "/xhprof_lib/utils/xhprof_runs.php"; $ xhprof_runs = new XHProfRuns_Default (); $ run_id = $ xhprof_runs-> save_run ($ data, "test ");
Access path:
xxx.
Xxx. xxx. xxx represents the server host
http://xxx.
Xxx. xxx. xxx/xhprof/xhprof_html/index. php? Run = $ run_id & source = test
I personally think that the access process can be encapsulated for ease of use.
The [View Full Callgraph] button can be used to View the time consumption distribution chart. If you click "View Full Callgraph", the following Error occurs: Error: either we can not find profile data for run_id 58b393370e400 or the threshold 0.01 is too small or you do not have 'dot 'image generation utility installed. error: we cannot find the configuration file data for run_id 58b393370e400 or the 0.01 threshold is too small or you have not installed the 'point' image generation utility. Xhprof draws a png image. The dot extension of the drawing is not successfully installed, that is, dot does not support PNG # yum install-y graphviz.
Wget http://pecl.php.net/get/xhprof-0.9.4.tgz tar zxvf xhprof-0.9.4.tgz cd xhprof-0.9.4 whereis phpize/usr/bin/phpize