之前已经编译好了nginx,但是此时需要添加一个未被编译的模块,此处以--with-http_realip_module为例。
1、查看当前nginx编译安装时安装了哪些模块
1 |
nginx -V |
1 2 3 4 5 |
nginx version: nginx/1.12.2 built by gcc 4.8.5 20150623 (Red Hat 4.8.5-16) (GCC) built with OpenSSL 1.0.2k-fips TLS SNI support enabled configure arguments: --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_v2_module --with-http_gzip_static_module --with-http_sub_module |
2、加入--with-http_sub_module模块,重新编译(注意:最后不需要执行make install)
1 2 3 4 5 6 |
cd /usr/local/src/ wget http://nginx.org/download/nginx-1.12.2.tar.gz tar zxf nginx-1.12.2.tar.gz cd /usr/local/src/nginx-1.12.2 ./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_v2_module --with-http_gzip_static_module --with-http_sub_module --with-http_realip_module make |
3、备份源文件并替换nginx的二进制文件
1 2 |
mv /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.bak cp objs/nginx /usr/local/nginx/sbin/nginx |
4、验证
1 |
nginx -V |
1 2 3 4 5 |
nginx version: nginx/1.12.2 built by gcc 4.8.5 20150623 (Red Hat 4.8.5-16) (GCC) built with OpenSSL 1.0.2k-fips TLS SNI support enabled configure arguments: --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_v2_module --with-http_gzip_static_module --with-http_sub_module --with-http_realip_module |
原文链接:nginx添加未被编译的模块,转载请注明来源!