首页 > 运维 > nginx > 正文

Nginx怎么配置检测服务状态

WBOY
发布: 2023-05-31 11:13:06
转载
2284 人浏览过

1. 查看是否安装检查状态模块;

[root@localhost ~]# nginx -v
nginx version: nginx/1.12.2
built by gcc 4.8.5 20150623 (red hat 4.8.5-36) (gcc)
configure arguments: --prefix=/usr/local/nginx --with-http_sub_module
登录后复制

2. 如未安装,重新编译安装;

ø 检查状态模块;--with-http_stub_status_module

[root@localhost ~]# cd /usr/local/src/nginx-1.12.2/       
[root@localhost ~]# ./configure --prefix=/usr/local/nginx --with-http_stub_status_module
[root@localhost ~]# make && make install
登录后复制

3. 编辑nginx 的配置文件;

[root@localhost ~]# vim /usr/local/nginx/conf/nginx.conf
server {
  listen 80;
  server_name localhost;
  #access_log logs/host.access.log main;
 
  location /nginx_status {
  stub_status on;
  access_log off;
   #allow 127.0.0.1; ##可对该页面的访问者进行过滤
   #deny all;
   }
  }
[root@localhost ~]# nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
[root@localhost ~]# nginx -s reload
登录后复制

4.测试语法;

[root@localhost ~]# curl http://192.168.10.110:80/nginx_status
active connections: 1
server accepts handled requests
 1 1 1
reading: 0 writing: 1 waiting: 0
登录后复制

5.     输出内容详解;

第一行  active connections: 1  ——活跃的连接数量,包括等待客户端数0
第二行 server accepts handled requests —— 总共处理了1个连接 , 成功创建1次握手, 总共处理了1个请求
第三行 reading — 读取客户端的连接数,writing — 响应数据到客户端的数量,waiting — 开启 keep-alive 的情况下,这个值等于 active – (reading+writing), 意思就是 nginx 已经处理完正在等候下一次请求指令的驻留连接.

以上是Nginx怎么配置检测服务状态的详细内容。更多信息请关注PHP中文网其他相关文章!

相关标签:
来源:yisu.com
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!