您的位置:首页 > 运维架构 > Nginx

nginx---stubstatus

2014-02-24 20:23 302 查看
今天在实践nginx的stubstatus的模块的时候,虚拟机可以,上服务器就不行了。搞了1个多小时。其实也就几行配置文件。

编辑nginx.conf文件

location /NginxStatus {

         stub_status         on;

         access_log         logs/NginxStatus.access.log;

         auth_basic         "NginxStatus";

         auth_basic_user_file         ../htpasswd;

}

htpasswd是通过apache中的htpasswd模块实现的,/usr/loca/apache/bin/htpasswd -c /usr/local/nginx/htpasswd moon

然后输入密码2次,

在配置文件中添加的那一段的意思:

auth_basic 是一种linux的认证机制。

auth_basic_user_file 通过htpasswd的模块生成一个moon用户,和密码。

stub_status         on;激活stubstatus模块。

在安装前首先要确定安装有http_stub_status_module模块,

[root@centos logs]# /usr/local/nginx/nginx -V

nginx version: nginx/1.4.2

built by gcc 4.1.2 20080704 (Red Hat 4.1.2-54)

TLS SNI support enabled

configure arguments: --sbin-path=/usr/local/nginx/nginx --conf-path=/usr/local/nginx/nginx.conf --pid-path=/usr/local/nginx/nginx.pid --with-http_ssl_module --with-pcre=/usr/local/src/pcre-8.21 --with-zlib=/usr/local/src/zlib-1.2.8 --with-openssl=/usr/local/src/openssl-1.0.1c
--with-http_stub_status_module --with-http_gzip_static_module

通过-V查看所有模块。

若没有此模块,需要重新编译。

进入nginx源码包。然后./configure  --sbin-path=/usr/local/nginx/nginx --conf-path=/usr/local/nginx/nginx.conf --pid-path=/usr/local/nginx/nginx.pid --with-http_ssl_module --with-pcre=/usr/local/src/pcre-8.21 --with-zlib=/usr/local/src/zlib-1.2.8 --with-openssl=/usr/local/src/openssl-1.0.1c
--with-http_stub_status_module --with-http_gzip_static_module

编译完后,make,切记不要make install(不然会覆盖原来的安装)。

然后将现在的nginx文件备份。mv /usr/local/nginx/nginx /usr/local/nginx/nginx.bak

将objs中的nginx cp 到/usr/local/nginx/下。

关键的一步来了。这里不能./nginx -s reload,热起会将PID继续沿用,也就是说 虽然你用了现在的nginx文件,但是应用的配置还是老的nginx.bak。

所以日志一直会报错

意思就是没有stub_status 这个模块。

所以需要./nginx -s stop 在./nginx就好了


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  nginx stub_status