本篇文章给大家分享的是有关Tideways、xhprof 和 xhgui 如何打造 PHP 非侵入式监控平台,小编觉得挺实用的,因此分享给大家学习,希望大家阅读完这篇文章后可以有所收获,话不多说,跟着小编一起来看看吧。
安装之前确保已经正确安装了以下软件
$ sudo pecl install mongodb
PHP 配置文件中添加
[mongodb]
extension=mongodb.so
常规编译安装
$ 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
$ 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',
...
);
$ 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 } )
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;
}
}
$ 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";
}
; Automatically add files before PHP document.
; http://php.net/auto-prepend-file
auto_prepend_file = "/path/wwwroot/xhgui-branch/external/header.php"
以上就是Tideways、xhprof 和 xhgui 如何打造 PHP 非侵入式监控平台,小编相信有部分知识点可能是我们日常工作会见到或用到的。希望你能通过这篇文章学到更多知识。更多详情敬请关注亿速云行业资讯频道。
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。