0.下载nginx-module-vts、解压
cd /etc/nginx/modules && wget https://github.com/vozlt/nginx-module-vts/archive/v0.1.18.tar.gz && tar -zxvf v0.1.18.tar.gz
1.查看nginx版本和编译参数
nginx -V
[root@base conf.d]
nginx version: nginx/1.17.10
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC)
built with OpenSSL 1.0.2k-fips 26 Jan 2017
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -fPIC' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -pie'
2.在官网下载1.17.10版本的nginx
cd /usr/local/src/ && wget http://nginx.org/download/nginx-1.17.10.tar.gz
3.解压,进入根目录
cd /usr/local/src/ && tar -zxvf nginx-1.17.10.tar.gz -C /usr/local/src/ && cd /usr/local/src/nginx-1.17.10
4.预编译
./configure + (configure arguments: 后的内容) + --add-module=/etc/nginx/modules/nginx-module-vts-0.1.18
./configure --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -fPIC' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -pie' --add-module=/etc/nginx/modules/nginx-module-vts-0.1.18
5.编译不安装
make
6.备份启动脚本,替换启动脚本
停止nginx
nginx -s stop
cp /usr/sbin/nginx /usr/sbin/nginx.back
cp /usr/local/src/nginx-1.17.10/objs/nginx /usr/sbin/nginx
启动nginx
nginx
7.查看插件安装成功
nginx -V
configure arguments: 最后是否有 --add-module=/etc/nginx/modules/nginx-module-vts-0.1.18
8.使用插件server配置/status
location /status {
vhost_traffic_status_display;
vhost_traffic_status_display_format html;
}
9.http配置vhost_traffic_status_zone
vhost_traffic_status_zone;
10.重启nginx访问
nginx -s stop
nginx
nginx -s reload 有时候不生效
http://192.168.1.25/status