记录一次yum安装nginx之后需要添加模块的操作

 

之前在centos7上yum安装了nginx,搭建了一个视频网站,但是发现在线播放MP4视频时无法在线播放,只能下载,查询了相关资料,说是有一个nginx_mod_h264_streaming模块未安装导致,于是尝试安装此模块,但是因为是yum安装,无configure --add-module参数,具体操作如下。

1. 先查看已安装的nginx版本  使用nginx -V

2.下载相同版本的nginx ,解压安装

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

    tar -zxvf nginx-1.12.2.tar.gz

3.备份原有配置,以免误操作之后可以还原

    cp /usr/sbin/nginx ~/nginx.back

    cp -r /ect/nginx ~/nginx.conf.back

4.编译nginx,添加模块,根据之前nginx -V获得的参数,再添加新的参数

./configure --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -fPIC' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -pie' --add-module=/usr/share/nginx_mod_h264_streaming-2.2.7

以上编译时,如出现缺少依赖,一般需要安装以下模块,安装完再次编译:

yum -y install libxml2 libxml2-dev libxslt-devel 
yum -y install gd-devel 
yum -y install perl-devel perl-ExtUtils-Embed 
yum -y install GeoIP GeoIP-devel GeoIP-data
yum -y install pcre-devel
yum -y install openssl openssl-devel

5.make 

make完成后不要继续输入“make install”,以免现在的nginx出现问题 
以上完成后,会在objs目录下生成一个nginx文件,先验证: 

/root/nginx-1.16.1/objs/nginx -t

/root/nginx-1.16.1/objs/nginx -V

添加nginx_mod_h264_streaming模块会报错

在文件: h264源码目录/src/ngx_http_streaming_module.c
将如下部分注释掉:

/* TODO: Win32 */

if (r->zero_in_uri)
{
return NGX_DECLINED;
}

 在文件: nginx源码目录/objs/Makefile
删除参数 -Werror

6.  替换Nginx文件并重启

cp /opt/nginx-1.12.2/objs/nginx /usr/sbin/

systemctl restart nginx 

7.检查nginx   nginx -V查看模块是否已经添加

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值