关于apm:Tideways-PHP-性能监控工具
Tideways PHP 性能监控工具1.简介php性能监控平台, 目前抉择的是tideways_xhprof扩大, xhgui UI展现界面, 应用mongoDb存储收集的日志数据具体版本,环境如下:Centos 7php7.4tideways_hprof 5.0 开源xghui 开源, 汉化版mongodb4, 存储日志2.装置a. 装置mongodb数据库yum install mongodb-server版本要大于3.6b. php mongodb 扩大1) pecl装置: pecl install mongodb 2) 安装包编译: mongodb下载地址 抉择适合版本,顺次执行以下命令编译装置wget -c https://pecl.php.net/get/mongodb-xxx.tgztar -zxvf mongodb-xxx.tgzcd mongodb-xxxphpize./configuremake && make install 3) yum 装置 以上办法三选一,轻易一个都能够。然而要留神php版本 4) 在php.ini中增加 extension=mongodb.so php.ini地位能够通过命令 php --ini 查看c. 装置tideways 扩大1) 执行以下命令,通过编译装置 git clone https://github.com/tideways/php-xhprof-extension.gitcd /path/php-xhprof-extensionphpize./configuremake && make install2) 在php.ini中增加 extension=tideways_xhprof.so 3) 重启php-fpm, 而后查看phpinfo(), 或php -m 看有没有胜利c. 装置xhgui UI1) 执行以下命令git clone https://github.com/laynefyc/xhgui-branch.git cd xhgui-branch php install.php // 初始化,装置依赖2) 批改配置文件 config/config.default.phpreturn array( ... 'extension' => 'tideways_xhprof', ... 'save.handler' => 'mongodb', 'db.host' => 'mongodb://127.0.0.1:27017', 'db.db' => 'xhprof', ...);d. 配置xhgui虚拟主机 nginxserver { listen 8081; server_name _; 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; }}e. mongodb加索引,进步查问速度$ 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 } )f. 在须要监控的我的项目nginx配置文件中退出探针$ fastcgi_param PHP_VALUE "auto_prepend_file=/path/xhgui-branch/external/header.php";示例(这是被监控的我的项目的config)server { listen XXXx; server_name XXXXX; 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";}G. 测试环境搭建胜利的示例猛戳这里