--with-http_stub_status_module 这个模块功能是记录nginx基本信息访问状态
1、检查编译是否有这个功能模块。
[root@slave nginx]# /usr/sbin/nginx -V
nginx version: nginx/1.8.0
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-17) (GCC)
built with OpenSSL 1.0.1e-fips 11 Feb 2013
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx/nginx.pid --lock-path=/var/lock/nginx.lock
--user=nginx --group=nginx --with-http_ssl_module --with-http_flv_module --with-http_realip_module --with-http_stub_status_module --with-http_gzip_static_module --http-client-body-temp-path=/var/tmp/nginx/client/ --http-proxy-temp-path=/var/tmp/nginx/proxy/
--http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi --http-scgi-temp-path=/var/tmp/nginx/scgi --with-pcre
[root@slave nginx]#
2、在目录下添加server段
##status
server {
listen 80;
server_name status.wolf.com;
location / {
stub_status on;
access_log off;
}
}
3、添加hosts
[root@slave nginx]# vi /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.0.203 www.wolf.com bbs.wolf.com blog.wolf.com wolf.com status.wolf.com
笔记本添加
[root@slave nginx]# vi /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.0.203 www.wolf.com bbs.wolf.com blog.wolf.com wolf.com status.wolf.com
4、语法检查
[root@slave nginx]# /usr/sbin/nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
5、重启服务
[root@slave nginx]# /usr/sbin/nginx -s reload
6、测试
浏览器http://status.wolf.com/访问
Active connections: 5
server accepts handled requests
54 54 408
Reading: 0 Writing: 1 Waiting: 4
[root@slave nginx]# curl status.wolf.com
Active connections: 6
server accepts handled requests
55 55 414
Reading: 0 Writing: 1 Waiting: 5
7、访问限制
##status
server {
listen 80;
server_name status.wolf.com;
location / {
stub_status on;
access_log off;
allow 192.168.0.0/24;
deny all;
}
}
8、访问log说明
active connections – 活跃的连接数量
server accepts handled requests — 总共处理了11989个连接 , 成功创建11989次握手, 总共处理了11991个请求
reading — 读取客户端的连接数.
writing — 响应数据到客户端的数量
waiting — 开启 keep-alive 的情况下,这个值等于 active – (reading+writing), 意思就是 Nginx 已经处理完正在等候下一次请求指令的驻留连接.
以上就介绍了 nginx信息功能启用,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。