部署xhprof监控php效率(linux版本) - Go语言中文社区

部署xhprof监控php效率(linux版本)


部署xhprof监控php效率

2015年5月26日 | 标签: php监控

1、安装xhprof扩展

下载地址:https://pecl.php.net/package/xhprof

2、配置php.ini

1
2
3
[xhprof]
extension=xhprof.so
xhprof.output_dir=/tmp

3、下载web界面程序并部署
下载地址:https://github.com/phacility/xhprof
将apache或者nginx解析地址解析到xhprof_html目录

4、在你需要监控的页面或者应用中添加代码
a/页头添加如下代码

1
2
3
if(extension_loaded('xhprof')) {
    xhprof_enable();
}

b/页尾添加如下代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
if(extension_loaded("xhprof")) {
     $xhprof_name= "test001";
     $XHPROF_ROOT= "/vagrant_data/xhprof";
     include_once$XHPROF_ROOT . "/xhprof_lib/utils/xhprof_lib.php";
     include_once$XHPROF_ROOT . "/xhprof_lib/utils/xhprof_runs.php";
 
     $xhprof_data= xhprof_disable();
     $xhprof_runs= newXHProfRuns_Default();
     $run_id= $xhprof_runs->save_run($xhprof_data,$xhprof_name);
 
     echo"---------------n".
     "Assuming you have set up the http based UI for n".
     "XHProf at some address, you can view run at n".
     "http://192.168.33.10:9998/index.php?run=$run_id&source=xhprof_foon".
     "---------------n";
}

5、访问解析到xhprof的url

 


来源:http://www.phpno.com/php-xhprof.html

版权声明:本文来源CSDN,感谢博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
原文链接:https://blog.csdn.net/gb4215287/article/details/59111185
站方申明:本站部分内容来自社区用户分享,若涉及侵权,请联系站方删除。
  • 发表于 2020-03-07 16:17:48
  • 阅读 ( 1000 )
  • 分类:Linux

0 条评论

请先 登录 后评论

官方社群

GO教程

猜你喜欢