Nginx中的stub_status模块主要用于查看Nginx的一些状态信息.
本模块默认是不会编译进Nginx的,如果你要使用该模块,则要在编译安装Nginx时指定:
<code><span>.</span>/configure –<span>with</span><span>-http_stub_status_module</span></code>
Java代码
<code>[root<span>@10</span>.<span>10.90</span>.<span>97</span> ~]<span># ./configure --prefix=/usr/local/nginx --with-http_stub_status_module </span> [root<span>@10</span>.<span>10.90</span>.<span>97</span> ~]<span># make && make install </span></code>
查看已安装的 Nginx 是否包含 stub_status 模块
<code><span>#/usr/local/nginx/sbin/nginx</span><span>-</span><span>V</span><span>nginx</span><span>version:</span><span>nginx/0</span><span>.</span><span>6</span><span>.</span><span>32</span><span>built</span><span>by</span><span>gcc</span><span>3</span><span>.</span><span>4</span><span>.</span><span>6</span><span>20060404</span><span>(Red</span><span>Hat</span><span>3</span><span>.</span><span>4</span><span>.</span><span>6</span><span>-</span><span>10)</span><span>configure</span><span>arguments:</span><span>-</span><span>-</span><span>user=nginx</span><span>-</span><span>-</span><span>group=nginx</span><span>-</span><span>-</span><span>prefix=/home/nginx</span><span>-</span><span>-</span><span>with</span><span>-</span><span>http_stub_status_module</span></code>
可以看到我安装了这个模块。注意是-V -v的话只会显示版本nginx version: nginx/0.6.32
开始配置nginx,在server块中加入location 就行了
<code>server{ location /nginx-status { allow <span>-------- </span> allow <span>--------//允许的ip </span> deny all<span>;// </span> stub_status <span><span>on</span>; </span> access_log off; } } </code>
重启nginx
killall -s HUP nginx
然后请求www.domain.com/nginx-status 就行了,下面是结果
<code><span>Active</span> connections: <span>5</span>server accepts handled requests <span>5970806143</span><span>5970806143</span><span>7560482010</span>Reading: <span>0</span> Writing: <span>5</span> Waiting: <span>0</span></code>
Active connections: 对后端发起的活动连接数.
Server accepts handled requests: Nginx总共处理了38810620个连接,成功创建38810620次握手(证明中间没有失败的),总共处理了298655730个请求.
Reading: Nginx 读取到客户端的Header信息数.
Writing: Nginx 返回给客户端的Header信息数.
Waiting: 开启keep-alive的情况下,这个值等于 active – (reading + writing),意思就是Nginx已经处理完成,正在等候下一次请求指令的驻留连接.
所以,在访问效率高,请求很快被处理完毕的情况下,Waiting数比较多是正常的.如果reading +writing数较多,则说明并发访问量非常大,正在处理过程中.
以上就介绍了welcome to nginx nginx 开启 stub_status 模块监控,包括了welcome to nginx方面的内容,希望对PHP教程有兴趣的朋友有所帮助。