nginx动态新增模块

很多时候nginx安装时候都是安装常用的模块,如果需要新增其他的模块时候要么重新安装在编译时把新增模块配置进去,在生产环境时不能这么操作的;这个时候就需要动态去增加nginx依赖模块。

1、安装nginx linux安装nginx
2、安装完成后,在nginx解压源码目录
cd /data/nginx

3、重新编译,这里需要注意的是,编译时候要加上原来增加的模块和新增加模块一起配置,如本次需要增加 --with-http_realip_module,原来已经编译时候已经增加 htpp ssl stream
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-stream --with-http_realip_module

4、编译完成后执行make,注意这里只要make 不需要make install,执行make install就会覆盖之前的安装
make

5、在make完成后在当前目录下会有obj目录,需要将obj目录下的nginx二进制文件覆盖原来的nginx二进制文件执行文件
cp ./obj/nginx /usr/local/nginx/sbin/nginx

6、重新启动nginx
nginx -s reload

7、如果不生效先停止ng再启动
nginx -s stop
nginx -c ./conf/nginx

8、如果配置得有nginx的service nginx自启
systemctl restart nginx
或者
systemctl stop nginx
systemctl start nginx

你可能感兴趣的:(nginx,nginx,运维)