目录
1、关闭防火墙、关闭核心防护
?2、解压nginx软件包
?3、安装依赖包
?4、创建用户
?5、进行编译安装
?编辑
?6、优化路径
?7、添加nginx系统服务
?8、检查开启的模块
?9、修改配置文件
在http以下插入
?在server下location下插入
?查看配置文件?编辑
?重启nginx
10、测试
访问网页http://192.168.127.199?查看服务是否启动
?访问网页http://192.168.127.199/status?查看服务是否启动
1、关闭防火墙、关闭核心防护

?2、解压nginx软件包
tar zxvf nginx-1.15.9.tar.gz
unzip nginx-module-vts-master.zip
mv nginx-module-vts-master /usr/local/



?3、安装依赖包
yum -y install gcc gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel make


?4、创建用户
useradd -M -s /sbin/nologon nginx

?5、进行编译安装
./configure \
> --prefix=/usr/local/nginx \
> --user=nginx \
> --group=nginx \
> --add-module=/usr/local/nginx-module-vts-master/


?
?6、优化路径

?7、添加nginx系统服务
[Unit]
Description=nginx
After=network.target
[Service]
Type=forking
PIDFile=/usr/local/nginx/logs/nginx.pid
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/bin/kill -s HUP $MAINPID
ExecStop=/usr/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target

?8、检查开启的模块

?9、修改配置文件
在http以下插入
vhost_traffic_status_zone;
log_format main '{ "@timestamp": "$time_local", '
'"@fields": { '
'"uri":"$request_uri",'
'"url":"$uri",'
'"upstream_addr":"$upstream_addr",'
'"remote_addr": "$remote_addr", '
'"remote_user": "$remote_user", '
'"body_bytes_sent": "$body_bytes_sent", '
'"host":"$host",'
'"server_addr":"$server_addr",'
'"request_time": "$request_time", '
'"request_time":"$request_time",'
'"status":"$status",'
'"request": "$request", '
'"request_method": "$request_method", '
'"size":$body_bytes_sent,'
'"upstream_time":"$upstream_response_time"'
'"http_referrer": "$http_referer", '
'"body_bytes_sent":"$body_bytes_sent", '
'"http_x_forwarded_for": "$http_x_forwarded_for", '
'"http_user_agent": "$http_user_agent" } }';
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';

?在server下location下插入
location /status {
vhost_traffic_status_display;
vhost_traffic_status_display_format html;

?查看配置文件
?重启nginx

10、测试
访问网页http://192.168.127.199?查看服务是否启动

?访问网页http://192.168.127.199/status?查看服务是否启动
?
?
|