xxxxxxxxxx
11$ wget https://pecl.php.net/get/xhprof-2.2.0.tgz
xxxxxxxxxx
11$ tar zxvf xhprof-2.2.0.tgz
xxxxxxxxxx
11$ mv xhprof-2.2.0 /usr/local/
xxxxxxxxxx
31$ cd /usr/local/xhprof-2.2.0/extension
2$ /usr/local/php/bin/phpize
3$ ./configure --with-php-config=/usr/local/php/bin/php-config
xxxxxxxxxx
11$ make && make install
xxxxxxxxxx
11$ vim /usr/local/php/lib/php.ini
新增如下内容:
xxxxxxxxxx
31extension=xhprof.so
2#图像输出目录
3xhprof.output_dir=/data/www/xhprof_ui
xxxxxxxxxx
31$ ps -ef | grep php-fpm
2$ kill -9 xxx
3$ /usr/local/php/sbin/php-fpm
xxxxxxxxxx
21$ cd /usr/local/nginx/conf.d
2$ vim localhost.phpinfo.com.conf
写入如下内容:
xxxxxxxxxx
341server {
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}
xxxxxxxxxx
21$ nginx -t
2$ nginx -s reload
xxxxxxxxxx
11$ cp -R /usr/local/xhprof-2.2.0 /data/www/xhprof
xxxxxxxxxx
111<?php
2xhprof_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