1. 首页
  2. 技术知识

nginx 添加http_stub_status_module模块

目录

    1. stub_status 作用说明2.查看现有 nginx 编译参数3.使用参数重新配置configure,在原有基础上添加上 –with-http_stub_status_module4.将原来的 nginx 文件备份5. 编译6. 替换nginx二进制文件7.重新启动nginx,查看编译参数8. 参考官网

      8.1 修改配置文件8.2 浏览器访问

1. stub_status 作用说明

编译选项 作用
–with-http_stub_status_module Nginx的客户端状态


2.查看现有 nginx 编译参数

  1. ./nginx -V
  2. # 如果没有我们需要的模块,例如本次试验添加的 –with-http_stub_status_module ,那么则需要重新编译安装一下

复制代码


3.使用参数重新配置configure,在原有基础上添加上 –with-http_stub_status_module

configure 文件是在安装包目录下的文件,具体可参考 centos 7 安装 nginx

  1. ./configure –prefix=/usr/local/nginx –with-http_realip_module –with-http_ssl_module –with-pcre –with-stream –with-http_stub_status_module

复制代码
4.将原来的 nginx 文件备份

  1. cp /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.bak

复制代码
5. 编译

  1. make
  2. # 这里是需要 make 编译,不用 make install

复制代码
6. 替换nginx二进制文件

  1. # 找到 nginx 安装包目录 /root/nginx-1.10.1/objs ,将 nginx 文件复制到原本的 /usr/local/nginx/sbin/nginx
  2. cp /root/nginx-1.10.1/objs/nginx /usr/local/nginx/sbin/

复制代码


7.重新启动nginx,查看编译参数

  1. ./nginx -s reload
  2. ./nginx -V

复制代码
8. 参考官网

地址:https://nginx.org/libxslt/en/docs/http/ngx_http_stub_status_module.html

8.1 修改配置文件

文件目录:/usr/local/nginx/conf

  1. # 在文件中添加新的 location
  2. location /nginx_status {
  3.         stub_status;
  4. }
  5. # 解释说明:
  6.         nginx_status        这是自定义命名的,访问的时候添加这个字段访问
  7.         stub_status;        这个是固定参数

复制代码


8.2 浏览器访问

  1. http://192.168.169.131/nginx_status
  2. # 访问内容结果如下图

复制代码

  1. # 解释说明:
  2. 1)Active connections-活跃连接数
  3.         The current number of active client connections including Waiting connections.
  4. (2)accepts-已接受的客户端连接总数
  5.         The total number of accepted client connections.
  6. (3)handled-已处理的连接总数
  7.         The total number of handled connections. Generally, the parameter value is the same as acceptsunless some resource limits have been reached (for example, the worker_connections limit).
  8. (4)requests-客户端连接总数
  9.         The total number of client requests.
  10. (5)Reading-读取请求头的当前连接数
  11.         The current number of connections where nginx is reading the request header.
  12. (6)Writing-将响应写回客户端的当前连接数
  13.         The current number of connections where nginx is writing the response back to the client.
  14. (7)Waiting-等待请求的当前空闲客户端连接数
  15.         The current number of idle client connections waiting for a request.

复制代码 参考官网地址:https://nginx.org/libxslt/en/docs/http/ngx_http_stub_status_module.html

到此这篇关于nginx 添加http_stub_status_module模块的文章就介绍到这了,更多相关nginx 添加http_stub_status_module内容请搜索软件技术网以前的文章或继续浏览下面的相关文章希望大家以后多多支持软件技术网!

原创文章,作者:starterknow,如若转载,请注明出处:https://www.starterknow.com/108943.html

联系我们