重新编译安装nginx
cd /opt/nginx-1.8.0./configure --with-http_stub_status_moduleecho $?makeecho $?make installecho $?
2.查看已安装的Nginx是否包含stub_status模块
[root@open*** nginx-1.8.0]# /usr/local/nginx/sbin/nginx -Vnginx version: nginx/1.8.0built by gcc 4.8.5 20150623 (Red Hat 4.8.5-4) (GCC)configure arguments: --with-http_stub_status_module
3.在已有的nginx配置文件(/usr/local/nginx/conf/nginx.conf)里增加以下内容
server { listen 8080; server_name localhost; root html; index index.html; access_log off; location /nginx_status { stub_status on; }}
以上内容就在http标签里即可,要和其它server标签独立分开。
4.语法检查
[root@open*** conf]# /usr/local/nginx/sbin/nginx -tnginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is oknginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
5.优雅重启已经不起作用,直接停止服务再启动
[root@open*** conf]# /usr/local/nginx/sbin/nginx -s stop[root@open*** conf]# ps -ef|grep nginxroot 4912 22321 0 15:12 pts/1 00:00:00 grep --color=auto nginxnginx 5722 1 0 Aug25 ? 00:00:00 /usr/bin/perl /data/local/nginx/perl-fcgi.pl -l /data/local/nginx/logs/perl-fcgi.log -pid /data/local/nginx/logs/perl-fcgi.pid -S /data/local/nginx/logs/perl-fcgi.sock[root@open*** conf]# /usr/local/nginx/sbin/nginx[root@open*** conf]# ps -ef|grep nginxroot 4923 1 0 15:12 ? 00:00:00 nginx: master process /usr/local/nginx/sbin/nginxnobody 4924 4923 0 15:12 ? 00:00:00 nginx: worker processroot 4931 22321 0 15:12 pts/1 00:00:00 grep --color=auto nginxnginx 5722 1 0 Aug25 ? 00:00:00 /usr/bin/perl /data/local/nginx/perl-fcgi.pl -l /data/local/nginx/logs/perl-fcgi.log -pid /data/local/nginx/logs/perl-fcgi.pid -S /data/local/nginx/logs/perl-fcgi.sock
6.端口已经打开
[root@open*** conf]# netstat -lntup|grep 8080tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 4923/nginx: master
7.执行结果成功
[root@open*** conf]# curl xx.xxx.xx.xxx:8080/nginx_statusActive connections: 1 server accepts handled requests 45 45 6 Reading: 0 Writing: 1 Waiting: 0
参考资料:http://xiaoluoge.blog.51cto.com/9141967/1642194