前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >编译安装 nginx的http_stub_status_module监控其运行状态

编译安装 nginx的http_stub_status_module监控其运行状态

作者头像
luxixing
发布2019-05-29 17:39:20
1K0
发布2019-05-29 17:39:20
举报
文章被收录于专栏:luxixingluxixing

步骤:

1 编译nginx,加上参数 --with-http_stub_status_module

以我自己的编译选项为例:

代码语言:javascript
复制
  #配置指令
  ./configure --prefix=/usr/local
    --user=nginx 
    --group=nginx
    --with-http_ssl_module
    --with-http_realip_module
    --http-client-body-temp-path=/usr/local/var/tmp/nginx/client 
    --http-proxy-temp-path=/usr/local/var/tmp/nginx/proxy 
    --http-fastcgi-temp-path=/usr/local/var/tmp/nginx/fcgi 
    --http-scgi-temp-path=/usr/local/var/tmp/nginx/scgi 
    --http-uwsgi-temp-path=/usr/local/var/tmp/nginx/uwsgi 
    --with-http_geoip_module 
    --with-http_stub_status_module

2 修改nginx配置文件,添加监控状态配置

在nginx.conf的server块中添加如下代码

代码语言:javascript
复制
location /nginx_status {
    # Turn on nginx stats
    stub_status on;
    # I do not need logs for stats
    access_log   off;
    # Security: Only allow access from 192.168.1.100 IP #
    #allow 192.168.1.100;
    # Send rest of the world to /dev/null #
    #deny all;
}

这段代码是加在默认的server里的, 假设默认server的配置为

代码语言:javascript
复制
listen       127.0.0.1:80;
server_name  127.0.0.1;

那么访问nginx的状态,就可以通过 curl 127.0.0.1/nginx_status访问了

返回结果类似于:

代码语言:javascript
复制
Active connections: 1 
server accepts handled requests
 655 655 1985 
Reading: 0 Writing: 1 Waiting: 0 
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档