基本环境:
LNMP环境
xhprof web项目包获取:
链接: https:///s/1_G0JeOrKW0nwfnSrlHb1xQ 提取码: iccj 复制这段内容后打开百度网盘手机App,操作更方便哦
#获取安装包
[root@server ~]# wget http:///get/xhprof-2.2.3.tgz
#安装依赖 graphviz
[root@server ~]# yum -y install gcc gcc-c++ autoconf graphviz
#编译安装
[root@server ~]# tar fx xhprof-2.2.3.tgz
[root@server ~]# cd xhprof-2.2.3
[root@server ~]# /usr/local/php/bin/phpize
[root@server ~]# ./configure --with-php-config=/usr/local/php/bin/php-config
[root@server ~]# make
[root@server ~]# make install
#配置php
[root@server ~]# cat /usr/local/php/etc/php.ini |grep xhprof -n
675:auto_prepend_file = "/opt/xhprof/xhprof_lib/utils/xhprof_inject.php"
1958:[xhprof]
1959:extension=xhprof.so
#生效
[root@server ~]# systemctl restart php-fpm
#配置数据库
CREATE DATABASE xhprof CHARACTER SET utf8 COLLATE utf8_bin;
GRANT ALL PRIVILEGES ON xhprof.* TO 'xhprof'@'localhost' IDENTIFIED BY 'xhprof';
CREATE TABLE `xhprof` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`request_host` varchar(255) DEFAULT NULL,
`uri` varchar(255) DEFAULT NULL,
`wall_time` bigint(20) unsigned DEFAULT NULL,
`cpu_time` bigint(20) unsigned DEFAULT NULL,
`m_use` bigint(20) unsigned DEFAULT NULL COMMENT 'memory use',
`pm_use` bigint(20) unsigned DEFAULT NULL COMMENT 'peak memory use',
`profile_data` mediumblob COMMENT 'xhprof data',
`client_ip` int(10) unsigned DEFAULT NULL COMMENT 'client ip',
`create_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5636 DEFAULT CHARSET=utf8;
#上传项目到 /opt
#数据库账号密码如果需要变更需要修改config.php , ./xhprof_lib/utils/xhprof_runs_db.php 这两个文件
#增加web用户权限 chown www:www -R /opt/xhprof_demo
#添加nginx配置文件
server {
listen 80;
server_name ;
charset utf-8;
root /opt/xhprof_demo/xhprof_html/;
index index.php index.html;
access_log /data/logs/nginx/xhprof_access.log;
error_log /data/logs/nginx/xhprof_error.log error;
location / {
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php/$1 last;
}
}
location ~ \.php$ {
include fastcgi.conf;
include fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_buffer_size 128k;
fastcgi_buffers 4 256k;
fastcgi_busy_buffers_size 256k;
}
location ~ /\.(ht|svn|git) {
deny all;
}
}
#systemctl reload nginx
版权声明:本文内容来自第三方投稿或授权转载,原文地址:https://blog.51cto.com/slapping/2856236,作者:类似简单,版权归原作者所有。本网站转在其作品的目的在于传递更多信息,不拥有版权,亦不承担相应法律责任。如因作品内容、版权等问题需要同本网站联系,请发邮件至ctyunbbs@chinatelecom.cn沟通。