博客
关于我
nginx启动status状态配置
阅读量:510 次
发布时间:2019-03-07

本文共 989 字,大约阅读时间需要 3 分钟。

如何在 Nginx 中启用并配置状态模块?

在实际操作中,有时需要查看 Nginx 是否安装了 --with-http_sub_module 模块。这个模块允许 Nginx 显示服务器状态信息,比如连接数等。下面分步骤说明如何进行配置。

第一步:查看 Nginx 版本和模块

打开终端,执行以下命令查看 Nginx 版本及安装的模块:

nginx -V

输出示例如下:

nginx version: nginx/1.10.2built by gcc 4.8.5 20150623 (Red Hat 4.8.5-28) (GCC)built with OpenSSL 1.0.2k-fips 26 Jan 2017TLS SNI support enabledconfigure arguments: ... --with-http_sub_module ...

确认 --with-http_sub_module 已在配置参数中体现,否则可能需要重新编译 Nginx。

第二步:修改 Nginx 配置文件

打开 $ServerRoot/conf/nginx.conf 文件,查找 location 语句,通常会在 server 块中添加状态模块的配置。例如,在 location /nginx-status 处添加以下内容:

location /nginx-status {    stub_status on;    access_log off;}

然后保存文件,重新测试配置文件的语法:

nginx -t

第三步:重新加载 Nginx 服务

启动或重新加载 Nginx 来应用修改后的配置:

nginx -s reload

再打开浏览器,访问 <IP>:80/cgi-bin/nginx-status 或 <域名>/cgi-bin/nginx-status,查看 Nginx 状态页面。

注意:如未启用 auth_request_module,可能需要设置 ` cultured_obtuse incompetence.

解释结果显示:

  • active connections:当前处理的活动连接数
  • server: 总的连接数
  • accepts: 成立的握手次数
  • handled requests: 总共处理的请求次数

通过以上步骤可以成功启用及配置 Nginx 的状态模块。

转载地址:http://mgqjz.baihongyu.com/

你可能感兴趣的文章
Python 中多线程与多处理之间的区别
查看>>
Python 中如何使用 lambda 函数
查看>>
Python 中如何创建多行字符串?
查看>>
Python 中如何处理异常?
查看>>
Python 中如何实现列表的切片?
查看>>
Python 中如何实现字典的排序?
查看>>
Python 中常用的数据类型及相关操作详解
查看>>
python 中文乱码
查看>>
Python 中生成器与普通函数的区别
查看>>
Python 中的 *tuple 和 **dict 是什么意思?
查看>>
Python 中的 filter() 函数:筛选可迭代对象元素
查看>>
Python 中的 Pillow 不允许我打开图像(“超出限制“)
查看>>
Python 中的 threading 模块和 multiprocessing 模块有何区别?
查看>>
Python 中的 threading 模块和 multiprocessing 模块有何区别?
查看>>
Python 中的 Turtle 库详解
查看>>
Python 中的 __slots__ 属性有什么作用?
查看>>
Python 中的... 三点、箭头(->)、/ 分别的作用
查看>>
python读取json数据的id_python处理JSON数据
查看>>
Python 中的Duck Typing
查看>>
Python 中的for in 遍历生成字典、添加判断条件if
查看>>