欢迎访问 生活随笔!

凯发ag旗舰厅登录网址下载

当前位置: 凯发ag旗舰厅登录网址下载 > 运维知识 > centos >内容正文

centos

centos7安装配置xhgui -凯发ag旗舰厅登录网址下载

发布时间:2025/1/21 centos 26 豆豆
凯发ag旗舰厅登录网址下载 收集整理的这篇文章主要介绍了 centos7安装配置xhgui 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

xhprof是facebook出品的一个php性能监控工具,只包含基本的界面和图形来分析数据。后来paul reinheimer在此基础上开发了xhgui,提供了更好的界面和功能,其凯发ag旗舰厅登录网址下载主页在https://github.com/perftools/xhgui,其实步骤说的很详细,但是在centos7上安装并不容易,因为很多程序需要编译,在这里记录一下

1、centos7最小安装, yum update 2、安装gcc, yum install net-tools gcc gcc-c wget vim 3、安装php, yum install php php-devel php-fpm git 4、下载nginx,        mkdir ~/download        cd ~/download       wget http://nginx.org/download/nginx-1.9.9.tar.gz       tar xvf nginx-1.99.tar.gz       cd nginx-1.99       yum install pcre-devel zlib-devel  (否则configure会出现错误)       ./configure        make        make install       nginx安装在/usr/local/nginx下 5、取消selinux,centos7确实很稳定安全,但是很麻烦,取消之后,避免出现一些奇怪的问题,      vim /etc/selinux/config      修改selinux=disabled      上面的方法需要重启,并且是长期有效的,临时性的方法是setenforce 0 6、创建nginx的80端口根目录,mkdir -p /data/html 7、修改nginx配置文件,vim /usr/local/nginx/conf/nginx.conf      修改http->server 80下的内容,如下          server {         listen       80;         server_name  localhost;         location / {             root   /data/html;             index  index.html index.htm;         }         error_page   500 502 503 504  /50x.html;         location = /50x.html {             root   /data/html;         }         location ~ \.php$ {             root           /data/html;             fastcgi_pass   127.0.0.1:9000;             fastcgi_index  index.php;             fastcgi_param  script_filename  $document_root$fastcgi_script_name;             include        fastcgi_params;         }     }     需要修改的地方,黑体字做了标注,location ~ \.php$需要取消注释 8、ln /usr/local/nginx/sbin/nginx /usr/sbin/nginx 9、systemctl auto php-fpm      systemctl start php-fpm 10、vim /data/html/info.php                       phpinfo();       curl localhost/info.php       说明php配置成功,需要注意,如果没有取消selinux,这里会出现file not found,如果一定要用selinux,需要赋予/data/html的www运行权限。 11、配置xhgui的步骤其实很简单,按照文档来就可以了 12、xhprof        cd ~/download        wget http://pecl.php.net/get/xhprof-0.9.4.tgz        tar xvf xhprof-0.9.4.tgz        cd xhprof-0.9.4/extension        phpize        ./configure        make        make install        vim /etc/php.ini        在最后加入        extension=xhprof.so       通过php -m可以看到xhprof.so已经安装成功 12、upprofiler        cd ~/download        git clone https://github.com/friendsofphp/uprofiler.git        cd uprofiler/extension        phpize        ./configure        make         make install        vim /etc/php.ini        最后加入        extension=uprofiler.so        用php -m验证 13、tideways        cd ~/download        git clone https://github.com/tideways/php-profiler-extension.git          cd php-profiler-extension/        phpize        ./configure        make         make install        vim /etc/php.ini        最后加入        extension=tideways.so        用php -m验证结果 14、 mongodb的php驱动        cd ~/download        wget http://pecl.php.net/get/mongo-1.6.12.tgz        tar xvf  mongo-1.6.12.tgz        cd mongo-1.6.12        phpize        yum install openssl-devel        ./configure        make && make install        vim /etc/php.ini        最后增加        extension=mongo.so        用php -m验证 15、安装mongodb       vim /etc/yum.repose.d/mongodb-org-3.2.repo       [mongodb-org-3.2]           name=mongodb repository           baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.2/x86_64/          gpgcheck=0          enabled=1 安装 yum install mongodb-org systemctl enable mongod systemctl start mongod 16、mcrypt cd ~/download wget  http://downloads.sourceforge.net/project/mcrypt/libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz tar xvf libmcrypt-2.5.8.tar.gz cd  libmcrypt-2.5.8 ./configure make make install cd ~/download wget http://museum.php.net/php5/php-5.4.16.tar.gz  cd php-5.4.16/ext/mcrypt/  phpize ./configure make make install vim /etc/php.ini 最后增加 extension=mcrypt.so 用php -m验证 17、dom cd ~/download/php-5.4.16/ext/dom/ yum install libxml2-devel phpize ./configure make make install vim /etc/php.ini 最后增加 extension=dom.so 用php -m验证 19、配置nginx,将xhgui放在88端口 vim /usr/local/nginx/conf/nginx.conf 增加 server{ listen 88; server_name localhost; root /data/xhgui/webroot; index index.php; location / { try_files $uri $uri/ /index.php?$uri&$args; } location ~ \.php$ { try_files $uri =404; include fastcgi_params; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param script_filename $document_root$fastcgi_script_name; } } cd /data git clone https://github.com/perftools/xhgui.git 打开防火墙端口 firewall-cmd --add-service=http firewall-cmd --permanent --add-service=http firewall-cmd --add-port=88/tcp firewall-cmd --permanent --add-port=88/tcp 19、对80端口注入xhgui文件 location ~ \.php$ { root           /data/html; fastcgi_pass   127.0.0.1:9000; fastcgi_index  index.php; fastcgi_param  script_filename  $document_root$fastcgi_script_name; include        fastcgi_params; fastcgi_param  php_value "auto_prepend_file=/data/xhgui/external/header.php"; } nginx -s reload 20、初始化 cd /data/xhgui php install.php 这一步包含下载composer,slim,以及初始化mongodb 21、 验证 curl localhost/info.php curl localhost:88 在这里88端口没有输出,是因为默认/etc/php.ini中设置了display_errors=off,修改为on 重启php-fpm, systemctl restart php-fpm 可以看到错误,是没有设置时区,修改/etc/php.ini 修改date.timezone = asia/chongqing 重启php-fpm, systemctl restart php-fpm curl localhost:88 如果配置正确的话,这里应该是正常的,没有错误 也可以在浏览器中访问,这台机器的ip为172.16.9.145,所以可以访问 http://172.16.9.145:88 22、测试程序 vim /data/html/test.php $n=5000;
$a = createarray($n);
$a = sortarray($a);
echoarray($a);
function createarray($n){
        $a;
        for($i=0;$i<$n;$i ){
                $a[$i]=rand(0,$n);
        }
        return $a;
}
function echoarray($a){
        for($i=0;$i                echo $a[$i]." ";
        }
}

function sortarray($a){
        for($i=0;$i                for($j=$i 1;$j                        if($a[$i]<$a[$j]){
                                $tmp = $a[$i];
                                $a[$i]=$a[$j];
                                $a[$j]=$tmp;
                        }
                }
        }
        return $a; } 其实很简单,就是一个创建数组,进行排序的过程,可以在浏览器中运行http://172.16.9.145/test.php,理论上就可以在http://172.16.9.145:88看到结果了, 但是,刷新88端口,一般是看不到结果的,这里是一个采样问题,xhgui是按照1%采样的,所以对于开发来说,需要100%采样,需要修改 vim /data/xhgui/config/config.php 'profiler.enable' => function() { //return rand(0,100) == 42 return rand(0, 100) > 0 ; }, 黑体子是修改内容,这就是100%的采样,再运行http://172.16.9.145/test.php,就可以在http://172.16.9.145:88上看到结果了, 可以看到采样的结果,包括程序的等待时间(wt)、cpu时间、内存等等信息,还可以通过view graphy看到函数调用的过程,颜色越深,说明运行越慢,需要处理。 23、其他 xhgui使用mongodb保存性能数据,数据库连接信息保存在xhgui/config/config.php中,这意味着可以将性能信息保存到远程机器,还可以将多台机器的性能数据放在一起,我们可以看一下性能数据的结构,如下 mongo >use xhprof >db.results.find().limit(1).pretty(); 查看一下键meta的信息,如下 "meta" : { "url" : "/test.php", "server" : { "user" : "apache", "home" : "/usr/share/httpd", "fcgi_role" : "responder", "script_filename" : "/data/html/test.php", "query_string" : "", "request_method" : "get", "content_type" : "", "content_length" : "", "script_name" : "/test.php", "request_uri" : "/test.php", "document_uri" : "/test.php", "document_root" : "/data/html", "server_protocol" : "http/1.1", "request_scheme" : "http", "gateway_interface" : "cgi/1.1", "server_software" : "nginx/1.9.9", "remote_addr" : "172.16.9.255", "remote_port" : "62433", "server_addr" : "172.16.9.145", "server_port" : "80", "server_name" : "localhost", "redirect_status" : "200", "php_value" : "auto_prepend_file=/data/xhgui/external/header.php", "http_host" : "172.16.9.145", "http_connection" : "keep-alive", "http_cache_control" : "max-age=0", "http_accept" : "text/html,application/xhtml xml,application/xml;q=0.9,image/webp,*/*;q=0.8", "http_upgrade_insecure_requests" : "1", "http_user_agent" : "mozilla/5.0 (windows nt 6.3; wow64) applewebkit/537.36 (khtml, like gecko) chrome/46.0.2490.86 safari/537.36", "http_accept_encoding" : "gzip, deflate, sdch", "http_accept_language" : "zh-cn,zh;q=0.8", "http_cookie" : "slim_session=1450653227|bxhi8+km+47xsntb+ozvav9qjphqyc1ocicfwhiblgi=|3a5b1cf4f47a77302d253b577949544f4ffe627b", "php_self" : "/test.php", "request_time_float" : 1450652599.176433, "request_time" : numberlong(1450652599) }, 可以通过server_*, http_*看到服务器信息,可以用来区分不同的主机,所以可以通过这些信息来过滤,可以支持多个主机               

转载于:https://www.cnblogs.com/stone-fly/p/5062389.html

总结

以上是凯发ag旗舰厅登录网址下载为你收集整理的centos7安装配置xhgui的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得凯发ag旗舰厅登录网址下载网站内容还不错,欢迎将凯发ag旗舰厅登录网址下载推荐给好友。

网站地图