因为要对缓存的网页进行解压,需要用到gunzip模块ngx_http_gunzip_module。

所以就在现有的nginx编译下新增一下,也就用这个当案例记录下。

先要知道自己原来都有编译了啥:

nginx -V

备份下原来的,比如我的:

--prefix=/usr/local/nginx --user=www --group=www --with-http_stub_status_module --with-http_v2_module --with-http_ssl_module --with-http_gzip_static_module --with-http_realip_module --with-http_flv_module --with-http_mp4_module --with-openssl=../openssl-1.1.1c --with-pcre=../pcre-8.43 --with-pcre-jit --with-ld-opt=-ljemalloc

现在进到nginx的文件夹,查看模块的编译参数。

./configure --help

其中只用到:--with-http_gunzip_module,那记住这句,复制下。

现在执行命令新增编译:

比如:

./configure --prefix=/usr/local/nginx --user=www --group=www --with-http_stub_status_module --with-http_v2_module --with-http_ssl_module --with-http_gzip_static_module --with-http_realip_module --with-http_flv_module --with-http_mp4_module --with-openssl=../openssl-1.1.1c --with-pcre=../pcre-8.43 --with-pcre-jit --with-ld-opt=-ljemalloc --with-http_gunzip_module

如果是第三方模块,就是:--add-module= ../模块

前面..也可以是你模块的具体文件夹路径。

等上面的命令走完之后,执行:make

然后执行:make install

命令跑完之后,备份下原来的nginx.conf文件,路径换成自己的。

mv /usr/local/nginx/sbin/nginx{,_bk}

然后用现在生成的替换原来的文件:

cp objs/nginx /usr/local/nginx/sbin

现在可以:nginx -t

看下有没有上面错误,没有就重启nginx。

现在可以看看刚才成功没,当然也可以之前就看。