飘在云端

东西南北,海角天涯

· 随笔 · · 295次浏览

为宝塔环境的nginx添加第三方模块

环境
宝塔面板7.0.3免费版,centos 7.7 x 64, nginx 1.17.7

特别说明:nginx必须是编译安装,如果是极速安装的nginx,configure后边添加第三方模块会没有效果,此时重新安装nginx,选择编译安装即可按后面步骤进行

提示:请备份nginx 主配置文件的自定义修改内容,不然操作完自定义修改的内容会丢失!

目标:
1>添加第三方webdav方法协议扩展模块实现对webdav完整支持
这里编译静态模块,webdav 完整扩展支持模块 可去github下载,或者搜索引擎搜 nginx-dav-ext-module github。
--with-http_dav_module --add-module=/path/to/nginx-dav-ext-module

2>为nginx添加tcp/udp代理模块实现端口转发
--with-stream

1.修改宝塔的nginx安装脚本:

vim /www/server/panel/install/nginx.sh

输入 :set nu 显示行号,定位到205行左右,在./configure开头的哪一行后面继续添加 --with-http_dav_module --add-module=/root/nginx-dav-ext-module-3.0.0 --with-stream

如下是我的完整编译参数:

./configure --user=www --group=www --prefix=${Setup_Path} ${ENABLE_LUA} --add-module=${Setup_Path}/src/ngx_cache_purge --add-module=${Setup_Path}/src/nginx-sticky-module --with-openssl=${Setup_Path}/src/openssl --with-pcre=pcre-${pcre_version} ${ENABLE_HTTP2} --with-http_stub_status_module --with-http_ssl_module --with-http_image_filter_module --with-http_gzip_static_module --with-http_gunzip_module --with-ipv6 --with-http_sub_module --with-http_flv_module --with-http_addition_module --with-http_realip_module --with-http_mp4_module --with-ld-opt="-Wl,-E" --with-cc-opt="-Wno-error" --with-http_dav_module --add-module=/root/nginx-dav-ext-module-3.0.0 --with-stream ${jemallocLD} ${ENABLE_NGX_PAGESPEED} ${ADD_EXTENSION}

2.重新编译nginx,install 后面接你想安装的nginx版本号,只需要精确到前2位版本号,如1.16、1.17

sh /www/server/panel/install/nginx.sh install 1.17

3.查看编译模块 nginx -V,可以看到添加成功了

评论 (0条)