centos7服务安装_流媒体服务器_安装nginx

转载于http://hdu104.com/294

3.安装配置Nginx
     
     3.1)先安装各种依赖(nginx需要pcre支持,yamdi用来为flv创建关键帧才能随意拖动)
     [root@AY130611215205Z ffmpeg-2.0.1]# yum install gcc gcc-c++ openssl-devel zlib-devel pcre pcre-devel yamdi
     
     3.2)下载所需的nginx模块
     第一个是nginx_mod_h264_streaming,让nginx支持flv/mp4流播放
     [root@AY130611215205Z ~]# wget http://h264.code-shop.com/download/nginx_mod_h264_streaming-2.2.7.tar.gz
     [root@AY130611215205Z ~]# tar zxvf nginx_mod_h264_streaming-2.2.7.tar.gz
     注意:先要修改一下这家伙的源码,注释掉nginx_mod_h264_streaming-2.2.7/src/ngx_http_streaming_module.c的158到161行
     /* TODO: Win32 */
     //if (r->zero_in_uri)
     // {
     //   return NGX_DECLINED;
     // }

     第二个是nginx-rtmp-module,让nginx支持rtmp/hls协议
     [root@AY130611215205Z ~]# wget -O nginx-rtmp-module.zip  https://github.com/arut/nginx-rtmp-module/archive/master.zip
     [root@AY130611215205Z ~]# unzip nginx-rtmp-module.zip
     下载清缓存的模块
     [root@AY130611215205Z ~]# wget -O ngx_cache_purge.ziphttps://github.com/FRiCKLE/ngx_cache_purge/archive/master.zip
     [root@AY130611215205Z ~]# unzip ngx_cache_purge.zip
     
     3.3)下载安装nginx
     [root@AY130611215205Z ~]# wget http://nginx.org/download/nginx-1.2.9.tar.gz
     [root@AY130611215205Z ~]# tar zxvf nginx-1.2.9.tar.gz
     [root@AY130611215205Z ~]# cd nginx-1.2.9
     [root@AY130611215205Z nginx-1.2.9]# ./configure –user=daemon –group=daemon –prefix=/usr/local/nginx/ –add-module=../nginx-rtmp-module-master –add-module=../ngx_cache_purge-master –add-module=../nginx_mod_h264_streaming-2.2.7 –with-http_stub_status_module –with-http_ssl_module –with-http_sub_module –with-http_gzip_static_module –with-http_flv_module
     [root@AY130611215205Z nginx-1.2.9]# make && make install
     PS:若提示make[1]: *** [objs/addon/src/ngx_http_h264_streaming_module.o] Error 1,请参考3.3.2小节的注意点,然后重新运行./configure这一段 
     
     /**———以下是安装了Tengine后重新编译的代码,模块的路径自己对一下———**//
./configure --add-module=../nginx-rtmp-module-master --add-module=../ngx_cache_purge-master --add-module=../nginx_mod_h264_streaming-2.2.7 --with-http_stub_status_module --with-http_ssl_module --with-http_sub_module --with-http_gzip_static_module --with-http_flv_module

     
     运行一下nginx
     [root@AY130611215205Z ~]# /usr/local/nginx/sbin/nginx
     然后用浏览器你的服务器IP,看到welcome就对了
     或者到nginx的sbin目录下,运行一下nginx -V,看看列表出来的modules对不对

 然后 cd /usr/local/nginx 
启动  ./nginx
优雅关闭   ./nginx -s quit
快速关闭   ./nginx -s stop

nginx -s reload  :修改配置后重新加载生效
nginx -s reopen  :重新打开日志文件
nginx -t -c /path/to/nginx.conf 测试nginx配置文件是否正确



默认nginx是不支持流媒体拖放等功能的,flv内置了这个支持,只需要加上–with-http_flv_module就可以了,flv视频需要加上关键帧,用yadmi处理一下就可以了yamdi -i in.flv out.flv

已经安装nginx时,先查看nginx编译环境
/usr/local/nginx/sbin/nginx -V
看看有没有–with-http_flv_module 没有的话就加上这句
复制已有的环境,后面加上–add-module=/root/chenwei/movie/nginx_mod_h264_streaming-2.2.7
./configure –user=www –group=www –prefix=/usr/local/nginx –with-http_stub_status_module –with-http_ssl_module –with-http_gzip_static_module –with-ipv6 –with-http_flv_module –add-module=/root/movie/nginx_mod_h264_streaming-2.2.7

make

ngx_http_streaming_module.c:158:8: 错误:‘ngx_http_request_t’没有名为‘zero_in_uri’的成员

找到ngx_http_streaming_module.c 158行
注释掉
if (r->zero_in_uri) { return NGX_DECLINED; } 这一段

../nginx_mod_h264_streaming-2.2.7/src/mp4_reader.c: 在函数‘esds_read’中:
../nginx_mod_h264_streaming-2.2.7/src/mp4_reader.c:377:16: 错误: 变量‘stream_priority’被设定但未被使用 [-Werror=unused-but-set-variable]
../nginx_mod_h264_streaming-2.2.7/src/mp4_reader.c:376:12: 错误: 变量‘stream_id’被设定但未被使用 [-Werror=unused-but-set-variable]
../nginx_mod_h264_streaming-2.2.7/src/mp4_reader.c: 在函数‘stsd_parse_vide’中:
../nginx_mod_h264_streaming-2.2.7/src/mp4_reader.c:529:22: 错误: 变量‘level_indication’被设定但未被使用 [-Werror=unused-but-set-variable]
../nginx_mod_h264_streaming-2.2.7/src/mp4_reader.c:528:22: 错误: 变量‘profile_compatibility’被设定但未被使用 [-Werror=unused-but-set-variable]
../nginx_mod_h264_streaming-2.2.7/src/mp4_reader.c:527:22: 错误: 变量‘profile_indication’被设定但未被使用 [-Werror=unused-but-set-variable]
../nginx_mod_h264_streaming-2.2.7/src/mp4_reader.c:526:22: 错误: 变量‘configuration_version’被设定但未被使用 [-Werror=unused-but-set-variable]
cc1: all warnings being treated as errors
make[1]: *** [objs/addon/src/mp4_reader.o] 错误 1
# vim objs/Makefile (修改objs/Makefile文件, 去掉其中的”-Werror”), 然后就能够正常编译了.
移动objs/nginx到nginx安装目录(/usr/local/nginx/sbin/nginx)

在网站配置文件中添加
location ~ .flv {
flv;
}
location ~ .mp4 {
mp4;
}

重启nginx
nginx -t
nginx -s reload



评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值