环境预备
装置以前确保曾经正确装置了如下软件
- 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 非侵入式监控平台的具体内容,更多请存眷资源魔其它相干文章!
标签: php开发教程 php开发资料 php开发自学 Tideways xhprof xhgui 打造 PHP 非侵入式监控平台
版权声明:除非特别标注,否则均为本站原创文章,转载时请以链接形式注明文章出处。