配置Nignx状态统计
1、下载vts模块
https://github.com/vozlt/nginx-module-vts
[root@client ~]# nginx -s stop
[root@client ~]# ls
anaconda-ks.cfg nginx-1.27.3
ceph-release-1-1.el7.noarch.rpm nginx-1.27.3.tar.gz
info.sh nginx-module-vts-master.zip
[root@client ~]# nginx -s stop
[root@client ~]# unzip nginx-module-vts-master.zip
2、编译nginx
如果没有编译安装过nginx,就用下面这个
./configure --prefix=/usr/local/nginx/ --add-module=/root/nginx-module-vts-master && make && make install
如果我们已经编译安装过了,就只需把vts模块添加进去就行然后编译,不安装
[root@client ~]# mv nginx-module-vts-master /usr/local/nginx/
[root@client ~]# nginx -V
nginx version: nginx/1.27.3
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC)
built with OpenSSL 1.0.2k-fips 26 Jan 2017
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx
[root@client ~]# nginx -V |grep vts #显示是没有vts模块的
nginx version: nginx/1.27.3
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC)
built with OpenSSL 1.0.2k-fips 26 Jan 2017
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx --with-compat --with-debug --with-file-aio --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_degradation_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_image_filter_module=dynamic
[root@client ~]# cd nginx-1.27.3/
[root@client nginx-1.27.3]# ./configure --prefix=/usr/local/nginx/nginx-module-vts-master/
[root@client nginx-1.27.3]# make[root@client nginx-1.27.3]# cd objs/
[root@client objs]# ./nginx -V #模块已经安装好了
nginx version: nginx/1.27.3
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC)
built with OpenSSL 1.0.2k-fips 26 Jan 2017
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx/ --add-module=/usr/local/nginx/nginx-module-vts-master/
[root@client objs]# mv /usr/local/nginx/sbin/nginx /opt/nginx.bak #备份nginx命令
[root@client objs]# cp ./nginx /usr/local/nginx/sbin/ #使用当前添加了vts模块的命令
[root@client objs]# vim /usr/local/nginx/conf/nginx.conf 修改配置
[root@client objs]# nginx 启用nginx
进入/usr/local/nginx/conf/nginx.conf里修改,修改好后,如上图启用nginx就可以了
##添加如下配置###vhost_traffic_status_zone; #添加这个server {listen 80;server_name localhost;charset utf-8;access_log logs/$server_addr.acce ss.log main;location / {root html;index index.html index.htm;}##添加如下配置####location /status { #这vhost_traffic_status_display;vhost_traffic_status_display_format html;} #到这儿,中间部分添加进去
去网页访问测试结果
http://192.168.235.140/status
这就欧克了