NGINX 之 状态模块实战 之五

1、检查NGINX是否安装了状态模块

[root@localhost nginx-1.6.3]# ./sbin/nginx -V        #--with-http_stub_status_module
nginx version: nginx/1.6.3
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-18) (GCC) 
TLS SNI support enabled
configure arguments: --user=www --group=www --with-http_ssl_module --prefix=/app/nginx-1.6.3 --with-http_stub_status_module

2、配置加载该模块

[root@localhost nginx-1.6.3]# vi conf/vhost/default.conf
server {
    listen       80;
    server_name  localhost;
    location / {
        root   html;
        index  index.html index.htm;
    }
    location /nginx_status {                   #nginx状态监控URL访问地址
        stub_status on;                            #启动状态监控
        access_log off;                             #关闭状态模块的日志功能,不影响正常日志
        allow 127.0.0.1;                            #只允许本机访问
        deny all;                                        #拒绝所有
    }
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   html;
    }
}

3、获取Nginx监控状态值

[root@localhost nginx-1.6.3]# curl http://127.0.0.1/nginx_status
Active connections: 1 
server accepts handled requests
 2 2 2 
Reading: 0 Writing: 1 Waiting: 0 

猜你喜欢

转载自blog.51cto.com/12965094/2144980