xxxxxxxxxx11$ wget https://pecl.php.net/get/xhprof-2.2.0.tgzxxxxxxxxxx11$ tar zxvf xhprof-2.2.0.tgzxxxxxxxxxx11$ mv xhprof-2.2.0 /usr/local/xxxxxxxxxx31$ cd /usr/local/xhprof-2.2.0/extension2$ /usr/local/php/bin/phpize3$ ./configure --with-php-config=/usr/local/php/bin/php-configxxxxxxxxxx11$ make && make installxxxxxxxxxx11$ vim /usr/local/php/lib/php.ini新增如下内容:
xxxxxxxxxx31extension=xhprof.so2#图像输出目录3xhprof.output_dir=/data/www/xhprof_uixxxxxxxxxx31$ ps -ef | grep php-fpm2$ kill -9 xxx3$ /usr/local/php/sbin/php-fpmxxxxxxxxxx21$ cd /usr/local/nginx/conf.d2$ vim localhost.phpinfo.com.conf写入如下内容:
xxxxxxxxxx341server {2 listen 80;3
4 set $prefix_host "localhost";5 set $app_name "xhprof";6 server_name localhost.xhprof.com;7
8 access_log /data/logs/$prefix_host/$app_name.access.log main;9 error_log /data/logs/localhost/xhprof.error.log;10
11 set $root_dir /data/www/xhprof/xhprof_html;12
13 location / {14 root $root_dir;15 try_files $uri $uri/ /index.php?$query_string;16 index index.html index.htm index.php;17 }18
19
20 error_page 500 502 503 504 /50x.html;21
22 location = /50x.html {23 root html;24 }25 location ~ \.php$ {26 root $root_dir;27 fastcgi_pass 127.0.0.1:9000;28 fastcgi_index index.php;29 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;30 fastcgi_param MODULE_NAME $app_name;31 include fastcgi_params;32 }33
34}xxxxxxxxxx21$ nginx -t2$ nginx -s reloadxxxxxxxxxx11$ cp -R /usr/local/xhprof-2.2.0 /data/www/xhprofxxxxxxxxxx111<?php2xhprof_enable(XHPROF_FLAGS_MEMORY + XHPROF_FLAGS_CPU + XHPROF_FLAGS_NO_BUILTINS);3
4// todo 逻辑代码5
6$xhprof_data = \xhprof_disable();7include_once '../xhprof/xhprof_lib/utils/xhprof_lib.php';8include_once '../xhprof/xhprof_lib/utils/xhprof_runs.php';9$xhprof_runs = new \XHProfRuns_Default();10$run_id = $xhprof_runs->save_run($xhprof_data, 'order-service');11?>yum install graphviz