nginx搭建基于http协议的视频点播服务器

摘要:
#error_log logs/error.log;#error_log logs/error.log信息;大客户机头缓冲器432k;gzip_类型文本/纯文本;客户端_标头超时3m;

1,于由自己的服务器上已经安装好nginx(具体安装方法见我的另一篇文章,Linux中安装nginx),所以不再安装。

2,下载nginx_mod_h264_streaming-2.2.7.tar.gz(自己在网上搜吧)。

3,安装pcre,先看有没有安装。

     

     [root@localhost vsftpd]# rpm -qa pcre
     pcre-7.8-7.el6.i686
 
     已经安装(上篇加rtmp模块的时候已经安装了)
 
4,解压nginx_mod_h264_streaming-2.2.7.tar.gz,添加flv,mp4模块。解压到和nginx源码同级的目录。然后./configure --add-module=../nginx_mod_h264_streaming-2.2.7 --with-http_flv_module --with-http_mp4_module
      因为flv 和http是nginx自带的所以不用下载这个模块。
 
 
5,make
      可能遇到问题1
      /root/nginx_mod_h264_streaming-2.2.7/src/ngx_http_streaming_module.c: In function ‘ngx_streaming_handler’:
     /root/nginx_mod_h264_streaming-2.2.7/src/ngx_http_streaming_module.c:158: error: ‘ngx_http_request_t’ has no member named ‘zero_in_uri’
     make[1]: *** [objs/addon/src/ngx_http_h264_streaming_module.o] Error 1
     make[1]: Leaving directory `/root/nnginx-1.5.9'
     make: *** [build] Error 2
     那么将src/ngx_http_streaming_module.c文件中以下代码删除或者是注释掉就可以了
 
6, make install
 
 
 
7,配置 nginx.conf

  

  #user  nobody;
worker_processes  1;
 
#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;
 
#pid        logs/nginx.pid;
 

events {
    worker_connections  1024;
}
 
#include  nginx.conf-rtmp;
 
http {
 
        include       mime.types;
 
        default_type  application/octet-stream;
 
        log_format main  '$remote_addr - $remote_user [$time_local] '
 
                                                '"$request" $status $bytes_sent '
 
                                                '"$http_referer" "$http_user_agent" '
 
                                                '"$gzip_ratio"';
 
        keepalive_timeout  60;
 
        server_names_hash_bucket_size  128;
 
        client_header_buffer_size    32k;
 
 
 
        large_client_header_buffers  4 32k;
 
 
 
        access_log off;
 
        gzip on;
 
        gzip_min_length  1100;
 
        gzip_buffers     4 8k;
 
        gzip_types       text/plain;
 
 
 
        output_buffers   1 32k;
 
        postpone_output  1460;
 
 
 
        client_header_timeout  3m;
 
        client_body_timeout    3m;
 
        send_timeout           3m;
 
 
 
        sendfile                on;
 
        tcp_nopush              on;
 
        tcp_nodelay             on;
 
 
 
######################################################################
 
 
 
    server {
    
            listen       8999;
    
            server_name  192.168.1.104;
    
            root    /usr/local/nginx/html/flv_file/;
    
            limit_rate_after 5m;   
            limit_rate 512k;        
    
    
            index   index.html;
    
            charset utf-8;
    
            location ~ .flv {
    
                flv;
    
            }
    
            location ~ .mp4$ {
                     mp4;
            }
    
    
            error_page   500 502 503 504  /50x.html;
    
            location = /50x.html {
    
                root   html;
    
            }
    }
 
}
 
8,启动nginx,创建/usr/local/nginx/html/flv_file/目录。
 
 
9,上传mp4视频文件CY.mp4。
 
 
10,写个html测试。看之前的文章用jwplayer来测试,但是我这边一直报jwplayer udefined。
 
<!DOCTYPE html>
<div id="container">Loading the player ...</div>
<video src="http://192.168.1.104:8999/CY.mp4" controls="controls" height="50%">
</video>

免责声明:文章转载自《nginx搭建基于http协议的视频点播服务器》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇分分钟教会你使用HTML写Web页面C++异常下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

nginx rewrite重写规则集合

本文根据网络搜索整理,不是原创 一.正则表达式匹配,其中: ~为区分大小写匹配 ~*为不区分大小写匹配 !~和!~* 分别为区分大小写不匹配及不区分大小写不匹配 . 匹配除换行符以外的任意字符 w 匹配字母或数字或下划线或汉字 s 匹配任意的空白符 d 匹配数字 匹配单词的开始或结束 ^匹配字...

nginx grok 正则错误的输出情况

nginx 配置: http { include mime.types; default_type application/octet-stream; log_format main '$http_host $server_addr $remote_addr [$time_local] "$request" '...

【nginx】大文件下载

nginx自带文件读取功能,而且实现地很好。 比如直接读取txt文件,png图片等,用chrome可以直接获取到内容。 但是对于很大的文件,比如有2个G的视频,nginx如何吐出2G的内容呢? 实验: 准备很大的MP4文件(比如2G),nginx搭建好webserver,nginx开启access_log选项(log中要包含下载文件大小,http code...

Windows 安装nginx并开机启动

Win安装nginx并 开机启动 下载nginx安装包 nginx-1.12.2.zip,解压到D盘。 https://pan.baidu.com/s/1InQa527yq35Q68c73RBb-A#list 下载 nginx-service.exe 和 nginx-service.xml 文件; https://pan.baidu.com/s/1InQ...

nginx配置https,重定向后https变成了http

nginx配置https如下 nginx 后面应用是对应的tomcat应用 server { listen 80; server_name xxxx.com; rewrite ^(.*) https://$server_name$1 permanent; } server { listen...

【转】PHP实现系统编程(四)--- 本地套接字(Unix Domain Socket)

原文:http://blog.csdn.net/zhang197093/article/details/78143687?locationNum=6&fps=1 ---------------------------------------------------------------------------------------------...