Nginx监控页面模块


Nginx监控页面模块安装

使用该模块可以记录我们Nginx客户端的基本访问状态信息。

情况1:Nginx未安装 

#在我们要进行编译安装时加入--with-http_stub_status_module模块

./configure --with-http_stub_status_module

#然后正常的编译安装后修改Nginx配置文件nginx.conf

http {
  .....
  server{
    .....
    #在server中加入下列配置  
    location /NginxStatus {
      stub_status on;
      access_log off;
    }
  }
} 

启动Nginx后就可以在浏览器中输入ip:端口/NginxStatus查看到我们Nginx客户端的基本访问状态信息。

情况2:Nginx已安装 

可以先在Nginx的sbin目录下输入./nginx -V 进行查看我们是否安装了--with-http_stub_status_module这个模块

    cd /opt/openresty/nginx/sbin

    ./nginx -V

停止Nginx服务

    cd /opt/openresty/nginx/sbin          #根据自己的Nginx安装路径

    ./nginx -s stop      

备份已安装好的 Nginx 的nginx文件

    cp /opt/openresty/nginx/sbin/nginx /opt/openresty/nginx/sbin/nginx.bak

    rm -rf /opt/openresty/nginx/sbin/nginx

回到原有的Nginx安装包下进行编译

    cd openresty-1.11.2.4/

    ./configure --prefix=/opt/openresty/nginx --with-http_stub_status_module    

    make 编译,注意这里千万不要make install

将重新编译后的nginx文件复制过去

    cp openresty-1.11.2.4/objs/nginx /opt/openresty/nginx/sbin/

修改Nginx配置文件nginx.conf

    vim /opt/openresty/nginx/conf/nginx.conf

http {
  .....
  server{
    .....
    #在server中加入下列配置  
    location /NginxStatus {
      stub_status on;
      access_log off;
    }
  }
} 

启动Nginx即可 

    cd /opt/openresty/nginx/sbin          #根据自己的Nginx安装路径

    ./nginx

启动Nginx后就可以在浏览器中输入ip:端口/NginxStatus查看到我们Nginx客户端的基本访问状态信息。