Nginx 添加MP4流媒体模块(LNMP1.0)

2013-07-02 11324点热度 2条评论

由于公司网站要用到在线视频,但是大部分时候不能在线缓冲播放。对客户体验很纠结。今天刚好在折腾就编译了一个。

以下是我的nginx的信息,如果符合可以试试

编译之前需要拿到之前编译的配置参数

nginx -V #查看编译配置参数

[root@bcsytv nginx-1.4.1]# nginx -V
nginx version: nginx/1.4.1
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-3) (GCC)
TLS SNI support enabled
configure arguments: --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-ipv6

接下来就可以开始了

cd /root/lnmp1.0-full
wget http://h264.code-shop.com/download/nginx_mod_h264_streaming-2.2.7.tar.gz
tar -zxvf nginx_mod_h264_streaming-2.2.7.tar.gz

首先备份我们之前的程序配置

mv /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.old

接着给nginx增加需要的模块

./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 --add-module=/root/lnmp1.0-full/nginx_mod_h264_streaming-2.2.7

等待,如果出现错误,需要注释掉nginx_mod_h264_streaming-2.2.7/src/ngx_http_streaming_module.c的以下内容:

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

接着返回/root/lnmp1.0-full/nginx-1.4.1

清除之前编译错误的模块,从新编译

make clean
./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 --add-module=/root/lnmp1.0-full/nginx_mod_h264_streaming-2.2.7
make
nginx -t
make install

如果成功你看到的应该是这样的内容

[root@bcsytv nginx-1.4.1]# nginx -V
nginx version: nginx/1.4.1
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-3) (GCC)
TLS SNI support enabled
configure arguments: --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-ipv6 --add-module=/root/lnmp1.0-full/nginx_mod_h264_streaming-2.2.7

接着就添加支持吧~
在server段中添加

location ~ .*.mp4${
mp4;
}

Jalena

原创内容,转载请注明出处! 部分内容来自网络,请遵守法律适用!

文章评论

  • 博友会

    效果看起来很不错

    2013-07-04