centos 7下nginx搭建流媒体服务器【动态添加模块】

服务器   发布日期:2025年06月19日   浏览次数:186

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上存在的用户,否则无权限访问(播放)文件]

 

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

  

 

以上就是centos 7下nginx搭建流媒体服务器【动态添加模块】的详细内容,更多关于centos 7下nginx搭建流媒体服务器【动态添加模块】的资料请关注九品源码其它相关文章!