一、安装查看是否是否安装xhprof扩展


php --ri xhprof #检查php是否有这个扩展




二、xhprof扩展的安装


$ wget http://pecl.php.net/get/xhprof-0.9.4.tgz  
$ tar -zxvf xhprof-0.9.4.tgz 
$ cd xhprof-0.9.4
$ cd extension/
$ phpize  -----------》phpize: command not found 解决 :yum install php-devel(注意:phpize 生成configure文件的)
$./configure --with-php-config=/usr/local/php/bin/php-config
$ make
$ make install
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.


三、配置 php.ini



[xhprof]extension=xhprof.so;; directory used by default implementation of the iXHProfRuns; interface (namely, the XHProfRuns_Default class) for storing; XHProf runs.;;xhprof.output_dir=<directory_for_storing_xhprof_runs>xhprof.output_dir=/tmp/xhprof
  • 1.

四、重启php-fpm或httpd服务



五、测试以及访问方式



把安装目录的文件夹拷贝到测试目录下

cp -Rf ./xhprof-0.9.4 /var/www/htm/

mv xhprof-0.9.4 xhprof #重命名文件


例子:

xhprof 安装使用及相关问题_php性能优化

第一种方式:复制上面到运行的结果(http路径),再次放入浏览器,填好前面对应的域名:

 http://192.168.0.109/xhprof/xhprof_html/index.php?run=5af543f2115f8&source=xhprof_foo

xhprof 安装使用及相关问题_xhprof_02


如果查看图形化展示 : yum install graphviz

xhprof 安装使用及相关问题_xhprof 安装使用_03