当前位置:   首页安装配置使用nginx搭建点播和直播流媒体主机的方法步骤

使用nginx搭建点播和直播流媒体主机的方法步骤

发布日期:2021-12-21 17:49 | 文章来源:gibhub

环境 centos7 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 -Ongx_cache_purge.zip https://github.com/FRiCKLE/ngx_cache_purge/archive/master.zip

5.下载nginx wget http://nginx.org/download/nginx-1.9.0.tar.gz

6 .进入nginx的安装目录下 执行以下命令./configure --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

7. 执行以下命令编译文件make && make install ,并修改nginx安装目录下的objs下的Makefile 删除-Werror

9. 修改nginx.conf

10. 通过yum 停止firewalld防火墙并卸载,然后安装iptables-services修改/etc/sysconfig/iptables文件夹放行80端口

11.nginx 配置如下:

#使用的用户和组
#user nobody;
#指定工作衍生的进程数,为cpu的核心数总和
worker_processes 2;
#指定错误日志的存放路径 日志记录级别[debug,info,notice,warn,error,crit]
error_log  /usr/local/nginx/logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#指定pid存放的路径
pid    /usr/local/nginx/logs/nginx.pid;
events {
  #使用的网络I/O模型,linux系统推荐是epoll而freeBSD是kqueue
  use epoll;
  #允许的连接数,最大的高并发连接数为worker_processes*worker_connections
  worker_connections 51200;
}
rtmp {
 server {
  listen 1935;
  chunk_size 4096;
  application live {
   live on;
   record off;
  }
  #application live2 {
   #live on;
   #record off;
  #}
  # video on demand
  application media {
   play /usr/local/nginx/html/;
  }
  #application vod_http {
   #play http://192.168.31.185/vod;
  #}
  application hls {
   live on;
   hls on;
   hls_path /tmp/hls;
  }
 }
}
http {
  include    mime.types;
  default_type application/octet-stream;
  #
  #log_format main '$remote_addr - $remote_user [$time_local] "$request" '
  #         '$status $body_bytes_sent "$http_referer" '
  #         '"$http_user_age

12. 输入xxx.xxx.xxx.xxx/*.mp4/*.flv就能播放视频了

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持本站。

联系我们
关于使用场景和技术架构的更多咨询,请联系我们的销售和技术支持团队。
Yingsoo Host

在线
客服

在线客服:7*24小时在线

客服
热线

400-630-3752
7*24小时客服服务热线

关注
微信

关注官方微信
顶部