nginx 投入生产之中,突然想重新编译 http_stub_status_module 模块

时间发生的背景:公司要求,要添加些nginx 的监控,其中包括什么连接数和握手之类的,发现 http_stub_status_module 这个模块应该被使用到,这样子通过 curl ip/nginx_status 即可抓取到想要的数据,非常方便。

下面因为安全方面的问题,所以就截图我自己搭建的虚拟机了,准备从头走一遍,步骤如下:
1、确定你的nginx 的源码包安装的路径,我这里是 /usr/local/nginx 中,源码包放在/usr/local/src 中,
nginx 投入生产之中,突然想重新编译 http_stub_status_module 模块

2、此时先使用二进制文件,对版本还有相关模块进行查询,
nginx 投入生产之中,突然想重新编译 http_stub_status_module 模块

3、下面来编译stub_status 这个模块
./configure --prefix=/usr/local/nginx --with-http_stub_status_module

4、注意注意,这时候只要 make编译,千万不要使用 make install
make

5、这时候,此路径下的objs 中已经重新产生了二进制nginx 文件
nginx 投入生产之中,突然想重新编译 http_stub_status_module 模块
6、对原二进制文件做好备份,并将新的二进制文件移入
mv /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx_backup
mv /usr/local/src/nginx-1.8.1/objs/nginx /usr/local/nginx/sbin
7、这时候查询文件 ./nginx -V 显示如图
nginx 投入生产之中,突然想重新编译 http_stub_status_module 模块

8、编辑 nginx.conf 文件,加上内容
nginx 投入生产之中,突然想重新编译 http_stub_status_module 模块
9、启动后使用curl -s 即可抓取自己想要的数据了
nginx 投入生产之中,突然想重新编译 http_stub_status_module 模块

猜你喜欢

转载自blog.51cto.com/12092988/2405041
今日推荐