背景:
使用apt一键安装了nginx,现在想安装nginx-rtmp-module模块
要求:
在不卸载nginx的情况下,重新编译安装nginx-rtmp-module模块
-
首先查看nginx版本及安装的模块
nginx -V
-
下载相同版本的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所带的模块
-
报错
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
- 替换旧nginx
make
在objs文件夹内会生成nginx可执行文件,whereis nginx命令查找旧nginx所在路径,复制新nginx文件到此路径即可完成