目录

一、准备安装包并解压

二、安装依赖的编译软件

三、编译安装nginx和模块

四、优化管理

五、修改配置文件

六、验证

七、监控模块各字段信


nginx中的vts模块是非常好用的一款监控模块,能让我们清晰的观测到服务器当下状态

一、准备安装包并解压

首先我们准备好nginx和vts的安装包

然后对其进行解压

tar -zxvf nginx-1.22.0.tar.gz

unzip nginx-module-vts-master.zip

mv nginx-module-vts-master /usr/local

 二、安装依赖的编译软件

yum -y install gcc gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel make

这里我是已经全部安装过了

三、编译安装nginx和模块

useradd -M -s /sbin/nologin nginx

#创建用户是为了让nginx更灵活,赋予更多的权限

./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --add-module=/opt/nginx-module-vts-master/

make && make install

这样就安装完成了

四、优化管理

ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/

nginx -V #查看nginx安装信息

这里vts模块也加载上了

nginx -t   #测试一下

五、修改配置文件

vim /usr/local/nginx/conf/nginx.conf   #配置文件如下

#user  nobody;
worker_processes  1;#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;#pid        logs/nginx.pid;events {worker_connections  1024;
}http {include       mime.types;default_type  application/octet-stream;vhost_traffic_status_zone;                  #流量状态监控#log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '#                  '$status $body_bytes_sent "$http_referer" '#                  '"$http_user_agent" "$http_x_forwarded_for"';#access_log  logs/access.log  main;
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" } }';sendfile        on;#tcp_nopush     on;#keepalive_timeout  0;keepalive_timeout  65;#gzip  on;server {listen       80;server_name  localhost;#charset koi8-r;#access_log  logs/host.access.log  main;location / {root   html;index  index.html index.htm;}location /status {vhost_traffic_status_display;vhost_traffic_status_display_format html;}#error_page  404              /404.html;# redirect server error pages to the static page /50x.html#error_page   500 502 503 504  /50x.html;location = /50x.html {root   html;}# proxy the PHP scripts to Apache listening on 127.0.0.1:80##location ~ \.php$ {#    proxy_pass   http://127.0.0.1;#}# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000##location ~ \.php$ {#    root           html;#    fastcgi_pass   127.0.0.1:9000;#    fastcgi_index  index.php;#    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;#    include        fastcgi_params;#}# deny access to .htaccess files, if Apache's document root# concurs with nginx's one##location ~ /\.ht {#    deny  all;#}}# another virtual host using mix of IP-, name-, and port-based configuration##server {#    listen       8000;#    listen       somename:8080;#    server_name  somename  alias  another.alias;#    location / {#        root   html;#        index  index.html index.htm;#    }#}# HTTPS server##server {#    listen       443 ssl;#    server_name  localhost;#    ssl_certificate      cert.pem;#    ssl_certificate_key  cert.key;#    ssl_session_cache    shared:SSL:1m;#    ssl_session_timeout  5m;#    ssl_ciphers  HIGH:!aNULL:!MD5;#    ssl_prefer_server_ciphers  on;#    location / {#        root   html;#        index  index.html index.htm;#    }#}}

nginx   #开启服务

nginx reload   #重新加载配置文件

六、验证

这样模块就成功添加完毕了

七、监控模块各字段信

监控列表各项信息
Server main 主服务器
**Host:**主机名
**Version:**版本号
**Uptime:**服务器运行时间
Connections active:当前客户端的连接数 reading:读取客户端连接的总数 writing:写入客户端连接的总数
Requsts accepted:接收客户端的连接总数 handled:已处理客户端的连接总数 Total:请求总数 Req/s:每秒请求的数量
Shared memory:共享内存 name:配置中指定的共享内存名称 maxSize:配置中指定的共享内存的最大限制 usedSize:共享内存的当前大小 usedNode:共享内存中当前使用的节点数
Server zones 服务器区域
zone:当前区域
Requests Total:请求总数 Req/s:每秒请求数 time:时间
Responses:状态码数量 1xx、2xx、3xx、4xx、5xx:表示响应不同状态码数量 Total:响应状态码的总数
Traffic表示流量 Sent:发送的流量 Rcvd:接收的流量 Sent/s:每秒发送的流量 Rcvd/s:每秒接收的流量
Cache表示缓存 Miss:未命中的缓存数 Bypass:避开的缓存数 Expirde:过期的缓存数 Stale:生效的缓存数 Updating:缓存更新的次数 Revalidated:重新验证的缓存书 Hit:缓存命中数 Scarce:未达缓存要求的请求次数Total:总数

Nginx编译安装+监控模块Nginx-module-vts相关推荐

  1. nginx编译安装,nginx静态资源访问和负载均衡的使用!

    一.前言 今天这篇文章呢,主要是总结一下过年期间复习的nginx负载均衡一些配置简单的实战演示! 二.nginx的常见使用 这里我主要演示nginx的源码安装以及相应的模块安装,然后讲解一下负载均衡的 ...

  2. LNMP平台搭建之一:nginx编译安装

    参考博客:https://www.cnblogs.com/zhang-shijie/p/5294162.html   jack.zhang 一.环境说明 系统环境:centos6.5 [root@lo ...

  3. Linux下Nginx编译安装后的开机自启动设置

    Linux下Nginx编译安装后的开机自启动设置 一.查看当前Nginx启动状态 二.而配置Nginx相关服务文件 三 .设置nginx命令 四.设置开机启动 五.测试开机启动 一.查看当前Nginx ...

  4. Linux下Nginx编译安装过程详解

    Linux下Nginx编译安装过程详解 一.Nginx介绍 二.Nginx源码下载 1.打开Nginx官网 2.下载官网的源码包 三.Nginx源码安装 1.解压源码包 2.安装开发包组及环境 3.编 ...

  5. linux nginx编译详解,Linux下nginx编译安装教程和编译参数详解

    这篇文章主要介绍了Linux下nginx编译安装教程和编译参数详解,需要的朋友可以参考下 一.必要软件准备 1.安装pcre 为了支持rewrite功能,我们需要安装pcre 复制代码 代码如下:# ...

  6. linux nginx编译安装mysql_Centos7下编译安装配置Nginx+PHP+MySql环境

    序言 这次玩次狠得.除了编译器使用yum安装,其他全部手动编译.哼~ 看似就Nginx.PHP.MySql三个东东,但是它们太尼玛依赖别人了. 没办法,想用它们就得老老实实给它们提供想要的东西. 首先 ...

  7. 宝塔Nginx编译安装headers_more模块

    前言 nginx 的 headers_more模块用于添加/修改/清除/请求/响应头的模块. 该模块主要有 4 个指令: more_set_headers 用于 添加.修改.清除 响应头 more_c ...

  8. Linux下nginx编译安装,重新添加模块

    Linux下nginx编译安装,重新添加模块 前言:编译完成后的Nginx,当我们需要新的功能模块时,要怎么重新添加呢?可以按照下面的方法试试. 1.查看nginx版本以及编译安装模块 [root@# ...

  9. 腾讯nginx编译安装

    源码编译安装 感谢云计算磊哥的开源 以下是编译安装和笔记整理 腾讯nginx编译安装 1. yum -y install gcc make zlib-devel pcre pcre-devel ope ...

最新文章

  1. 推特雪花算法 java实现
  2. 【PC工具】虚拟串口工具Configure Virtual Serial Port Driver6.9汉化版
  3. 数据库性能检查指导方案
  4. 七种方式求斐波那契(Fibonacci)数列通项
  5. OpenCV3学习(8.2)直方图相似度比较compareHist函数与EMD距离
  6. php7 memcached dll,php7.1和7.2的memcache.dll文件
  7. JavaScript内建对象 (一) ----- Array
  8. 【经验】win11上安装visio
  9. Excel线性回归分析
  10. 给SLAM小车添加 手柄遥控 功能 罗技F710和PS4 手柄
  11. 《华为研发》阅读 - 11 (中研部组织结构)
  12. 各项数字技术的发展历程
  13. Qt 常用文件对话框及消息对话框使用
  14. 【2021年】百度搜索词获取,获取百度搜索的关键词
  15. Luogu P1725 琪露诺
  16. html 苹果 地图,pdrLocationIos0508.html
  17. 使用QT5书写的护眼程序
  18. 计算机三级考哪个容易过关,计算机等级考试三级PC技术过关心得技巧
  19. HGAME 2023 Week1
  20. 程序设计的三种基本结构

热门文章

  1. abap内表的操作汇总
  2. 微信投票小程序系统设计与实现
  3. java 动态 ip_java实现动态切换上网IP
  4. python虚拟环境venv、virtualenv
  5. 当“信用配送”来敲门,达达、美团配送、蜂鸟即配怎么玩?
  6. 苏格拉底和孔子的区别
  7. 2021Shopee退款退货政策
  8. 塞尔达正在维护服务器,我的世界1.8服务器塞尔达
  9. An HTTP error occurred when trying to retrieve this URL. HTTP errors are often intermittent......
  10. Android 源码修改,使第三方应用可以直接使用su命令