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地址即可进行测试

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值