centos服务器搭建nginx服务器+RMTP流传输

centos服务器搭建nginx服务器+RMTP流传输

1.安装必要库

yum install -y gcc-c++
yum install -y pcre pcre-devel
yum install -y zlib zlib-devel
yum install -y openssl openssl-devel

2.安装nginx和nginx-rtmp-module

我的目录在/root里面操作

nginx-1.17.10.tar.gz下载地址
http://nginx.org/en/download.html
nginx-rtmp-module-master.zip下载地址
https://codeload.github.com/arut/nginx-rtmp-module/zip/master

tar -zxvf nginx-1.17.10.tar.gz
upzip nginx-rtmp-module-master.zip
cd nginx-1.17.10
./configure --add-module=../nginx-rtmp-module-master
make
make install

3.修改配置文件

vim /usr/local/nginx/conf/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;
}

rtmp_auto_push on;

rtmp {
    server {
        listen 1935;
    chunk_size 4096;


    application live{
        live on;
    }
   
        application hls {  
            live on;  
            hls on;  
            hls_path /tmp/hls;  
        } 
    }

}


http {
    include       mime.types;
    default_type  application/octet-stream;


    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html;
            index  index.html index.htm;
        }
        
        location /stat {
                rtmp_stat all;

                # Use this stylesheet to view XML as web page
                # in browser
                rtmp_stat_stylesheet stat.xsl;
            }

        location /stat.xsl {
                # XML stylesheet to view RTMP stats.
                # Copy stat.xsl wherever you want
                # and put the full directory path here
                root /root/nginx-rtmp-module-master/stat.xsl/;
            }

            location /hls {
                # Serve HLS fragments
                types {
                    application/vnd.apple.mpegurl m3u8;
                    video/mp2t ts;
                }
                root /tmp;
                add_header Cache-Control no-cache;
            }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }


    }


}

修改完后要去阿里云服务器配置安全组规则打开1935端口

4.启动nginx服务器

/usr/local/nginx/sbin/nginx

打开对应的ip地址和ip/stat地址
ip地址
在这里插入图片描述
ip/stat地址
在这里插入图片描述
有以上显示代表配置成功

5.测试RTMP视频流
这里我提供一个不错的测试网页
https://download.csdn.net/download/pk296256948/12446208
最终打开页面是这样
在这里插入图片描述
修改ip地址即可进行测试

展开阅读全文

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 大白 设计师: CSDN官方博客
应支付0元
点击重新获取
扫码支付

支付成功即可阅读