nginx安装nginx-rtmp-module视频流媒体播放服务器模块

来源:互联网 发布:phaser.js 编辑:程序博客网 时间:2024/05/29 17:30

一、下载 nginx-rtmp-module

官方github地址:https://github.com/arut/nginx-rtmp-module

git clone https://github.com/arut/nginx-rtmp-module.git 

如果无法执行 -bash: git: command not found  说明没有安装git

安装git: yum -y install git

二、安装:nginx

wget http://nginx.org/download/nginx-1.8.1.tar.gz

tar -zxvf nginx-1.8.1.tar.gz

cd nginx-1.8.1

./configure --prefix=/usr/local/nginx  --add-module=../nginx-rtmp-module  --with-http_ssl_module

make && make install

安装中遇到的问题:

问题1:编译C 问题(在nginx-1.8.1目录下)  yum install gcc gcc-c++

问题2:make编译问题(在nginx-1.8.1目录下)yum -y install openssl openssl-devel

问题3:./configure:  error: the HTTP rewrite module requires the PCRE library.错误

yum -y install pcre-devel

三、修nginx配置文件


vim /usr/local/nginx/conf/nginx.conf

在文件里加入下面内容(加载在最后面就行,独立模块)

rtmp {   
   
    server {   
   
        listen 1935;  #监听的端口 
   
        chunk_size 4000;   
            
        application hls {  #rtmp推流请求路径 
            live on;   
            hls on;   
            hls_path /usr/local/nginx/html/hls;   
            hls_fragment 5s;   
        }   
    }   
}
还有就是这个路径,看你自己的实际情况的访问根目录来,我的是/usr/local/nginx/html/这个路径,然而/usr/local/nginx/html/hls肯定没有这个目录,所以需要建一个放流文件的目录hls,并且需要改权限可读可写的权限

修改http中的server模块:

主要是改了一下端口号,改成了81;然后root目录 按实际情况改!

server { 
        listen       81; 
        server_name  localhost; 
     
        #charset koi8-r; 
     
        #access_log  logs/host.access.log  main; 
     
        location / { 
            root   /usr/local/nginx/html; 
            index  index.html index.htm; 
        } 
     
        #error_page  404              /404.html; 
     
        # redirect server error pages to the static page /50x.html 
        # 
        error_page   500 502 503 504  /50x.html; 
        location = /50x.html { 
            root   html; 
        }

然后启动nginx:

/usr/local/nginx/sbin/nginx

关于更多rtmp的参数可以参考:https://github.com/arut/nginx-rtmp-module/wiki



参考地址:http://www.cnblogs.com/lipcblog/p/6824145.html

               http://blog.csdn.net/ystyaoshengting/article/details/48436409  如何安装nginx第三方模块--add-module



阅读全文
0 0
原创粉丝点击