百分百源码网-让建站变得如此简单! 登录 注册 签到领金币!

主页 | 如何升级VIP | TAG标签

当前位置: 主页>网站教程>网页制作> Tideways、xhprof 和 xhgui 打造 PHP 非侵入式监控平台
分享文章到:

Tideways、xhprof 和 xhgui 打造 PHP 非侵入式监控平台

发布时间:09/01 来源:未知 浏览: 关键词:

环境预备

安置此前确保已经准确安置了以下软件

  • PHP
  • Nginx
  • Mongodb

安置 PHP mongodb 扩展

$ sudo pecl install mongodb

PHP 配置文件中增加

[mongodb]
extension=mongodb.so

安置 PHP tideaways 扩展

常规编译安置

$ git clone https://github.com/tideways/php-xhprof-extension.git
$ cd /path/php-xhprof-extension
$ phpize
$ ./configure
$ make
$ sudo make install

PHP 配置文件中增加

[tideways]
extension=tideways_xhprof.so
; 不需要主动加载,在程序中操纵就行
tideways.auto_prepend_library=0
; 频率设定为100,在程序调取时可以修改
tideways.sample_rate=100

安置 xhgui-branch(xhgui 的汉化版)

$ git clone https://github.com/laynefyc/xhgui-branch.git
$ cd xhgui-branch
$ php install.php

修改 xhgui-branch 配置文件

<?php
return array(
     ...
    'extension' => 'tideways_xhprof',
     ...
    'save.handler' => 'mongodb',
    'db.host' => 'mongodb://127.0.0.1:27017',
    'db.db' => 'xhprof',
     ...
);

启动 mongodb 并设定 xhgui 索引,命令如下:

$ mongo

> use xhprof
> db.results.ensureIndex( { 'meta.SERVER.REQUEST_TIME' : -1 } )
> db.results.ensureIndex( { 'profile.main().wt' : -1 } )
> db.results.ensureIndex( { 'profile.main().mu' : -1 } )
> db.results.ensureIndex( { 'profile.main().cpu' : -1 } )
> db.results.ensureIndex( { 'meta.url' : 1 } )

xhgui 当地虚拟主机配置参照

server {
    listen       80;
    server_name  xhgui.test;
    root         /Users/yaozm/Documents/wwwroot/xhgui-branch/webroot;

    # access_log  /usr/local/var/log/nginx/access.log;
    error_log  /usr/local/var/log/nginx/error.log;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
        index  index.php index.html index.htm;
    }
}

针对要剖析的站点停止设定,直接在要剖析站点的 nginx 配置中增添以下项,然后使配置生效就可以了。

$ fastcgi_param PHP_VALUE "auto_prepend_file=/path/xhgui-branch/external/header.php";

参照 配置

server {
    listen       80;
    server_name  laravel.test;
    root         /Users/yaozm/Documents/wwwroot/laravel/public;

    # access_log  /usr/local/var/log/nginx/access.log;
    error_log  /usr/local/var/log/nginx/error.log;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
        index  index.php index.html index.htm;
    }
     # 增加 PHP_VALUE,告诉 PHP 程序在施行前要调取的效劳
    fastcgi_param PHP_VALUE "auto_prepend_file=/path/wwwroot/xhgui-branch/external/header.php";
}

或者也可以在修改 PHP 配置文件,告诉 PHP 程序在施行前要调取的效劳

; Automatically add files before PHP document.
; http://php.net/auto-prepend-file
auto_prepend_file = "/path/wwwroot/xhgui-branch/external/header.php"

更多PHP相关技术文章,请拜访PHP教程栏目停止学习!

以上就是Tideways、xhprof 和 xhgui 打造 PHP 非侵入式监控平台的具体内容,更多请关注百分百源码网其它相关文章!

打赏

打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,你说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

百分百源码网 建议打赏1~10元,土豪随意,感谢您的阅读!

共有151人阅读,期待你的评论!发表评论
昵称: 网址: 验证码: 点击我更换图片
最新评论

本文标签

广告赞助

能出一分力是一分吧!

订阅获得更多模板

本文标签

广告赞助

订阅获得更多模板