Nginx怎么配置检测服务状态
这篇文章主要介绍“Nginx怎么配置检测服务状态”,在日常操作中,相信很多人在Nginx怎么配置检测服务状态问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”Nginx怎么配置检测服务状态”的疑惑有所帮助!接下来,请跟着小编一起来学习吧!
1.查看是否安装检查状态模块;
[root@localhost~]#nginx-vnginxversion:nginx/1.12.2builtbygcc4.8.520150623(redhat4.8.5-36)(gcc)configurearguments:--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&&makeinstall
3.编辑nginx 的配置文件;
[root@localhost~]#vim/usr/local/nginx/conf/nginx.confserver{listen80;server_namelocalhost;#access_loglogs/host.access.logmain;location/nginx_status{stub_statuson;access_logoff;#allow127.0.0.1;##可对该页面的访问者进行过滤#denyall;}}[root@localhost~]#nginx-tnginx:theconfigurationfile/usr/local/nginx/conf/nginx.confsyntaxisoknginx:configurationfile/usr/local/nginx/conf/nginx.conftestissuccessful[root@localhost~]#nginx-sreload
4.测试语法;
[root@localhost~]#curlhttp://192.168.10.110:80/nginx_statusactiveconnections:1serveracceptshandledrequests111reading:0writing:1waiting:0
5. 输出内容详解;
第一行 activeconnections:1 ——活跃的连接数量,包括等待客户端数0第二行server accepts handled requests —— 总共处理了1个连接 , 成功创建1次握手, 总共处理了1个请求第三行 reading — 读取客户端的连接数,writing — 响应数据到客户端的数量,waiting — 开启 keep-alive 的情况下,这个值等于 active – (reading+writing), 意思就是 nginx 已经处理完正在等候下一次请求指令的驻留连接.
到此,关于“Nginx怎么配置检测服务状态”的学习就结束了,希望能够解决大家的疑惑。理论与实践的搭配能更好的帮助大家学习,快去试试吧!若想继续学习更多相关知识,请继续关注网站,小编会继续努力为大家带来更多实用的文章!