博客
关于我
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可维护性_使用这7大神器,让你的Python 代码更容易于维护
查看>>
Python只运行一次while循环
查看>>
python变量的详细教程_Python零基础入门教程之语法入门[变量](第二期)
查看>>
Python变量命名方法-ChatGPT4o作答
查看>>
Python变量与运算符
查看>>
Python变量/运算符/函数/模块/string
查看>>
python发送邮件的时候出现 error (535, b‘5.7.3 Authentication unsuccessful‘) 解决方法
查看>>
python系列【仅供参考】:python flask框架 debug功能
查看>>
python发送notes邮件_使用python在Lotus Notes中发送邮件
查看>>
Python双版本下创建一个Scrapy(西瓜皮)项目
查看>>
Python双版本下No module named 'requests'
查看>>
python及pycharm2018软件安装教程
查看>>
python去重txt文本_Python实现的txt文件去重功能示例
查看>>
python去掉列表的逗号,从Python列表项中删除标点符号
查看>>
Python卸载所有包
查看>>
python单线程下实现多个socket并发
查看>>
Python单元测试框架介绍(超详细~)
查看>>
Python单元测试框架
查看>>
python单元测试之unittest
查看>>
Python单元测试unittest实战
查看>>