zoukankan      html  css  js  c++  java
  • centos 7下nginx搭建流媒体服务器【动态添加模块】

    1、安装nginx依赖包 yum install gcc gcc-c++ openssl-devel zlib-devel pcre pcre-devel yamdi

    2.下载解压nginx_mod_h264_streaming,让nginx支持flv,mp4流播放
    wget http://h264.code-shop.com/download/nginx_mod_h264_streaming-2.2.7.tar.gz
    解压后需要修改src目录下的ngx_http_streaming_module.c文件,将r->zero_in_uri所在的if语句注释掉

    3.下载解压nginx-rtmp-module,让nginx支持rtmp/hls协议,
    wegt -o nginx-rtmp-module.zip https://github.com/arut/nginx-rtmp-module/archive/master.zip

    4下载清除缓存的模块 wget -O ngx_cache_purge.zip https://github.com/FRiCKLE/ngx_cache_purge/archive/master.zip

    5、使用./nginx -V查看已经配置安装的模块
    在原有基础添加模块 --add-module=...
    流媒体搭建模块如下:
    ./configure --add-module=/usr/local/nginx-1.13.1/additional/nginx-rtmp-module-master --add-module=/usr/local/nginx-1.13.1/additional/ngx_cache_purge-master --add-module=/usr/local/nginx-1.13.1/additional/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

    6、使用make命令【已经安装了nginx就不要使用make install命令】

    7、备份原有nginx执行文件
    cp nginx nginx.bak【在/usr/local/nginx/sbin目录下】

    8、更新新模块执行文件
    cp /objs/nginx /usr/local/nginx/sbin/ 【在安装目录下】

    注:

    访问可能出现的问题:
    403 forbidden
    no permit

    解决方法:将nginx.conf头部文件修改为:user nginx[必须是linux上存在的用户,否则无权限访问(播放)文件]

    nginx.conf
    
    rtmp模块实例
    rtmp { #RTMP服务
      server {
        listen 1935; #服务端口 
        chunk_size 4096; #数据传输块的大小
    
        application vod {
          play /data/movie/vod/; #视频文件存放位置。
        }
      }
    }
    
    http模块实例
    location /video/ {
      #注意root 与 alias区别:
      #如果以下变成root则访问test.mp4文件地址为:
      #/data/movie/vod/video/test.mp4文件地址为:
      #否则alias时为:/data/movie/vod/test.mp4
      alias /data/movie/vod/;
      autoindex on;#这个默认是off的 意思是禁止访问目录
    }
    

      

    大道,在太极之上而不为高;在六极之下而不为深;先天地而不为久;长于上古而不为老
  • 相关阅读:
    函数特化
    模板函数总结
    学习代码1
    宏指令
    #define宏作用
    oracle 重要函数
    JMeter 系列之—-01 使用
    Selenium系列之--03 常见元素操作总结
    【转】TestNG常用注解
    CMMI 2,3,4,5级涉及的过程域(PA)介绍
  • 原文地址:https://www.cnblogs.com/GodBug/p/7384647.html
Copyright © 2011-2022 走看看