nginx编译添加新的模块

1、已经安装好的nginx,需要添加一个未被编译安装的模块,以安装第三方ngx_http-google_filter_module模块为例
#cd /tmp/
#pkill nginx
#wget https://nginx.org/download/nginx-1.16.0.tar.gz
#tar xfz nginx-1.16.0.tar.gz
#cd nginx-1.16.0/
#./configure --prefix=/usr/local/nginx --with-http_gzip_static_module && make && make install

2、 下载第三方扩展模块
#cd /tmp/
#git clone https://github.com/cuber/ngx_http_google_filter_module #先安装git

3、查看nginx编译安装以安装模块
#cd /tmp/
#git clone https://github.com/cuber/ngx_http_google_filter_module #先安装git
15.2、查看nginx编译安装以安装模块
#cd /usr/local/nginx/sbin/
#./nginx -v //查看版本
#./nginx -V //查看以安装模块
加入需要安装的模块,重新编译,如这里添加-add-module=/data/software/ngx http_google_filter_module
#cd /tmp/nginx-1.16.0/
#./configure --prefix=/usr/local/nginx \

–error-log-path=/var/log/nginx/nginx_error.log
–http-log-path=/var/log/nginx/nginx_access.log
–pid-path=/usr/local/nginx/run/nginx.pid
–with-http_image_filter_module
–with-http_ssl_module
–with-http_realip_module
–with-http_addition_module
–with-http_sub_module
–with-http_dav_module
–with-http_flv_module
–with-http_gzip_static_module
–with-http_stub_status_module
–with-http_perl_module
–with-mail
–with-mail_ssl_module
–with-pcre
–http-client-body-temp-path=/var/tmp/nginx/client/
–http-proxy-temp-path=/var/tmp/nginx/proxy
–http-fastcgi-temp-path=/var/tmp/nginx/fcgi
–http-uwsgi-temp-path=/var/tmp/nginx/uwsgi
–http-scgi-temp-path=/var/tmp/nginx/scgi
–add-module=/tmp/ngx_http_google_filter_module/

#make //注意这里!!!是make千万别make install那样会覆盖安装,相当于重新安装了!
出现错误
nginx编译添加新的模块
解决方法:
#cd /tmp/
#git clone git://github.com/yaoweibin/ngx_http_substitutions_filter_module.git
#cd nginx-1.16.0/
#./configure --prefix=/usr/local/nginx --error-log-path=/var/log/nginx/nginx_error.log --http-log-path=/var/log/nginx/nginx_access.log --pid-path=/usr/local/nginx/run/nginx.pid --with-http_image_filter_module --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_gzip_static_module --with-http_stub_status_module --with-http_perl_module --with-mail --with-mail_ssl_module --with-pcre --http-client-body-temp-path=/var/tmp/nginx/client/ --http-proxy-temp-path=/var/tmp/nginx/proxy --http-fastcgi-temp-path=/var/tmp/nginx/fcgi --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi --http-scgi-temp-path=/var/tmp/nginx/scgi --add-module=/tmp/ngx_http_substitutions_filter_module/ --add-module=/tmp/ngx_http_google_filter_module
#cd /usr/local/nginx/sbin/
#ls
#ll nginx
#mv nginx /nginx.bak
#cd /tmp/nginx-1.16.0/
#ls
#cd objs/
#ls
#mv nginx /usr/local/nginx/sbin/
#cd /usr/local/nginx/sbin/
#ls
#cd /usr/local/nginx/
#ls
#cd conf/
#vim nginx.conf //把error_log和pid前面的#去掉
#cd /tmp/nginx-1.16.0/
#mkdir -p /usr/local/lib64/perl5/auto/nginx
#cp objs/src/http/modules/perl/blib/arch/auto/nginx/nginx.bs objs/src/http/modules/perl/blib/arch/auto/nginx/nginx.so /usr/local/lib64/perl5/auto/nginx
#cp objs/src/http/modules/perl/blib/lib/nginx.pm /usr/local/lib64/perl5/
#/usr/local/nginx/sbin/nginx
#lsof -i:80
#ps aux |grep nginx
#cd /usr/local/nginx/sbin/
#./nginx -V

最后结果如下图所示
nginx编译添加新的模块