Nginx整合mp4,flv模块

注:
nginx 1.1.3之后已经默认支持mp4,flv模块,无须第三方模块支持。
 
操作步骤:
1:解压,编译nginx,编译添加mp4,flv模块:
# tar -zxvf nginx-1.3.14.tar.gz
# cd nginx-1.3.14
# ./configure 
# ./configure --prefix=/usr/local/nginx --user=nobody --group=nobody --with-select_module --with-poll_module --with-file-aio --with-http_ssl_module --with-http_realip_module --with-http_gzip_static_module --with-http_secure_link_module --with-http_sub_module --with-http_stub_status_module --with-http_perl_module --with-http_mp4_module --with-http_flv_module
# make&& make install

2:配置nginx.conf文件:(server选项配置)
# limit_conn_zone $binary_remote_addr zone=perip:10m;
server {
    listen 80 ;
    server_name 117.27.135.82;
    root  /usr/local/nginx/html/mp4_file/;    ----------根路径
    limit_rate 256k;
 
    location ~ \.flv$                      ---------匹配flv文件
    {
        flv;
    }
 
    location ~ \.mp4$                    ----------匹配mp4文件
    {
    mp4;
#    mp4_buffer_size    1m;       
#    mp4_max_buffer_size  5m;
    limit_rate_after 5m;                ---------下载5m后再限速
    limit_rate 100k;                    ----------限速100k
#    limit_conn perip 1;
    }

3:下载JWplayer,实现视频可拖拽功能。解压,并把player.swf文件放到视频文件目录下。

播放测试:
 在根目录下放入mp4文件VGA.mp4。在浏览器上播放视频。
 地址:http://xx.xx.xx.xx/player.swf?type=http&file=VGA.mp4  (player.swf为播放器,VGA.mp4为要播放的视频文件)
 能正常播放,说明配置成功,如下图:

更多Nginx相关教程见以下内容

Nginx 的详细介绍请点这里
Nginx 的下载地址请点这里

猜你喜欢

转载自www.linuxidc.com/Linux/2016-07/133143.htm