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对不对
启动 ./nginx
优雅关闭 ./nginx -s quit
快速关闭 ./nginx -s stop
nginx -s reload :修改配置后重新加载生效
nginx -s reopen :重新打开日志文件
nginx -t -c /path/to/nginx.conf 测试nginx配置文件是否正确