目录
一、Nginx
一款高性能、轻量级Web服务软件
1.稳定性高
2.系统资源消耗低.
3.对HTTP并发连接的处理能力高
单台物理服务器可支持30000 ~ 50000个并发请求
二、监控
1.准备环境
yum -y install gcc gcc-c++ pcre-devel zlib-devel make
2.创建用户
useradd -M -s /sbin/nologin nginx
3. 解压并移动
unzip nginx-module-vts-master.zip
mv nginx-module-vts-master /usr/local/
ls /usr/local/
4.编译安装
cd /opt
tar xzvf nginx-1.15.9.tar.gz
cd nginx-1.15.9/
./configure \
--prefix=/usr/local/nginx \
--user=nginx \
--group=nginx \
--add-module=/usr/local/nginx-module-vts-master/
add module 添加模块
make && make install
5.路径优化
ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/
6.确认
nginx -t 检查配置文件是否配置正确
7.修改配置文件
cd /usr/lib/systemd/system
vim nginx.service
[Unit]
Description=nginx
After=network.target
[Service]
Type=forking
PIDFile =/usr/local/nginx/logs/nginx.pid
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.targe
chmod 754 /lib/systemd/system/nginx.service
systemctl start nginx.service
systemctl start nginx
systemctl status nginx
cd /usr/local/nginx/conf
vim nginx.conf
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":&