linux下不卸载nginx安装第三方模块

背景:
使用apt一键安装了nginx,现在想安装nginx-rtmp-module模块
要求:
在不卸载nginx的情况下,重新编译安装nginx-rtmp-module模块

  1. 首先查看nginx版本及安装的模块

    nginx -V
    jietu

  2. 下载相同版本的nginx和模块

    git clone https://github.com/arut/nginx-rtmp-module.git

    wget http://nginx.org/download/nginx-1.14.0.tar.gz

解压nginx后进入目录

./configure --with-cc-opt='-g -O2 -fdebug-prefix-map=/build/nginx-FIJPpj/nginx-1.14.0=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -Wdate-time -D_FORTIFY_SOURCE=2' --with-ld-opt='-Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -fPIC' --prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --modules-path=/usr/lib/nginx/modules --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --with-debug --with-pcre-jit --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_auth_request_module --with-http_v2_module --with-http_dav_module --with-http_slice_module --with-threads --with-http_addition_module --with-http_geoip_module=dynamic --with-http_gunzip_module --with-http_gzip_static_module --with-http_image_filter_module=dynamic --with-http_sub_module --with-http_xslt_module=dynamic --with-stream=dynamic --with-stream_ssl_module --with-mail=dynamic --with-mail_ssl_module --add-module=/root/nginx-rtmp-module

注意最后为要添加的模块路径,前面的为已安装nginx所带的模块

  1. 报错
    3.1
    checking for GD library … not found
    checking for GD library in /usr/local/ … not found
    checking for GD library in /usr/pkg/ … not found
    checking for GD library in /opt/local/ … not found
    ./configure: error: the HTTP image filter module requires the GD library.
    You can either do not enable the module or install the libraries.
    解决办法:

    apt install libgd-dev
    apt install libwebp-dev -y
    apt install libperl-dev -y

3.2
checking for GeoIP library … not found
checking for GeoIP library in /usr/local/ … not found
checking for GeoIP library in /usr/pkg/ … not found
checking for GeoIP library in /opt/local/ … not found
./configure: error: the GeoIP module requires the GeoIP library.
You can either do not enable the module or install the library.
解决办法:

apt  install libgeoip-dev -y

3.3
root/nginx-rtmp-module/ngx_rtmp_stat_module.c: In function ‘ngx_rtmp_stat_handler’:
/root/nginx-rtmp-module/ngx_rtmp_stat_module.c:771:67: error: macro “DATE” might prevent reproducible builds [-Werror=date-time]
NGX_RTMP_STAT_L("" DATE " " TIME “\r\n”);
^
/root/nginx-rtmp-module/ngx_rtmp_stat_module.c:771:67: error: macro “TIME” might prevent reproducible builds [-Werror=date-time]
cc1: all warnings being treated as errors
objs/Makefile:1725: recipe for target ‘objs/addon/nginx-rtmp-module/ngx_rtmp_stat_module.o’ failed
make[1]: *** [objs/addon/nginx-rtmp-module/ngx_rtmp_stat_module.o] Error 1
make[1]: Leaving directory ‘/root/nginx-1.14.0’
Makefile:8: recipe for target ‘build’ failed
make: *** [build] Error 2
解决办法:
去掉参数中的-Wdate-time

  1. 替换旧nginx
   make

在objs文件夹内会生成nginx可执行文件,whereis nginx命令查找旧nginx所在路径,复制新nginx文件到此路径即可完成
success

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值