Ubuntu14.04下 安装xhprof

1.下载xhprof包:

wget http://pecl.php.net/get/xhprof-0.9.4.tgz

 

2.解压 进入扩展目录

tar zxvf xhprof-0.9.4.tgz

cd /home/justphp/xhprof-0.9.4/extension

 

3.使用phpize在当前目录编译源码

*由于我使用的事apt-get 安装的php环境 此时发展根本找不到phpize工具, 于是还得 安装php开发包php5-dev

 php5-dev是用来开发php扩展的,提供一些用来开发、编译php5扩展程序的必要php组件

apt-get install php5-dev //先安装php开发包

/usr/bin/phpize    //在xfprof扩展目录运行 生成源文件
./configure --with-php-config=/usr/bin/php-config  //生成配置文件

 

4.编译

 

直至扩展目录信息提示: Installing shared extensions: /usr/lib/php5/20121212/

 

 5.配置php.ini 

vim  /etc/php5/fpm/php.ini

添加:

[xhprof]
extension=/usr/lib/php5/20121212/xhprof.so;
;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

 

6.重启php 生效xhprof扩展

/etc/init.d/php5-fpm restart

重启过多次 发现phpinfo中都没发现xhprof, 最后重启系统 才搞定!

 

7.安装图形绘制工具软件

 apt-get install graphviz

 

 

8.应用到php项目 进行性能测试

xhprof_enable(XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY);

#这里是项目代码 最好放在入口文件


$data = xhprof_disable();

include_once "xhprof_lib/utils/xhprof_lib.php";  //xhprof源码包中文件 -->/home/justphp/xhprof-0.9.4/xhprof_lib/utils/xhprof_lib.php
include_once "xhprof_lib/utils/xhprof_runs.php"; //xhprof源码包中文件 -->/home/justphp/xhprof-0.9.4/xhprof_lib/utils/xhprof_runs.php
$objXhprofRun = new XHProfRuns_Default();//数据会保存在php.ini中xhprof.output_dir设置的目录去中  

$run_id = $objXhprofRun->save_run($data, "test");

 

9.结果

 

 

 

 

 

参考:http://www.cnblogs.com/wangtao_20/archive/2013/09/13/3320497.html

 

转载于:https://www.cnblogs.com/justphp/p/6537874.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值