zoukankan      html  css  js  c++  java
  • nginx 搭建 rtmp 服务器

    搭建nginx + nginx-rtmp-module
    演示的系统使用CentOS-7-x86_64-Everything-1611.iso

    关闭防火墙

    请根据实际情况调整防火墙。为了演示方便,博主关闭防火墙。
    临时停止

    systemctl stop firewalld
    

    禁用

    systemctl disable firewalld
    

    查看状态

    systemctl status firewalld
    

    安装wget

    yum -y install wget
    

    安装 gcc gcc-c++

    yum -y install gcc gcc-c++
    

    安装PCRE库

    cd /usr/local/
    wget http://jaist.dl.sourceforge.net/project/pcre/pcre/8.33/pcre-8.33.tar.gz
    tar -zxvf pcre-8.33.tar.gz
    cd pcre-8.33
    ./configure
    make && make install
    

    安装openssl

    cd /usr/local/ 
    wget http://www.openssl.org/source/openssl-1.0.1j.tar.gz 
    tar -zxvf openssl-1.0.1j.tar.gz 
    cd openssl-1.0.1j
    ./config
    make && make install
    

    nginxrtmp2.jpg
    如果提示You need Perl 5,则输入下面这个命令。

    yum -y install Perl 5
    

    安装zlib

    cd /usr/local/
    wget http://zlib.net/zlib-1.2.11.tar.gz
    tar -zxvf zlib-1.2.11.tar.gz
    ./configure
    make && make install
    

    git clone

    cd /usr/local/
    yum -y install git
    git clone https://github.com/arut/nginx-rtmp-module.git 
    

    安装nginx

    cd /usr/local/
    wget http://nginx.org/download/nginx-1.8.0.tar.gz
    tar -zxvf nginx-1.8.0.tar.gz
    cd nginx-1.8.0
    ./configure --prefix=/usr/local/src/nginx --with-http_stub_status_module --with-http_gzip_static_module --with-http_realip_module --with-http_sub_module --with-http_ssl_module  --add-module=../nginx-rtmp-module  --with-openssl=<path> --with-http_ssl_module
    make && make install 
    

    如果提示

    ./configure: error: SSL modules require the OpenSSL library.
    

    执行

    yum -y install openssl openssl-devel
    

    如果提示

     ./configure: error: the HTTP rewrite module requires the PCRE library.
    

    执行

    yum -y install pcre-devel
    

    我下载并安装了pcre-8.33.tar.gz 和 openssl-1.0.1j.tar.gz ,并没有出现上面的错误

    nginx相关命令

    启动

    /usr/local/src/nginx/sbin/nginx
    

    重启

    /usr/local/src/nginx/sbin/nginx –s reload
    

    启动后,打开浏览器,输入服务器ip地址,访问显示如下页面,则表示成功安装。
    nginxrtmp3.jpg

    修改conf

    nginxrtmp4.jpg
    使用 winscp 前往/usr/local/src/nginx/conf/nginx.conf
    在 http{ 前加入

    rtmp {
        server {
            listen 1935; #监听的端口
            chunk_size 4000; #上传文件块的大小
    
            application yuchen { #创建一个名为 yuchen 的应用
                live on; #开启实时
                #allow publish 127.0.0.1;
                #allow play all;
                hls on; #开启hls
                hls_path /usr/local/nginx/html/yuchen; #rtmp推流请求路径,文件存放路径 (切记路径错了会推不上流)
                hls_fragment 5s; #每个TS文件包含5秒的视频内容
            }
       }
    }

    修改完成后,使用命令重启nginx

    /usr/local/src/nginx/sbin/nginx –s reload
    

    推拉流

    打开obs推流,右下角变为绿色方块则推流成功。
    nginxrtmp5.jpg

    在potplayer中播放http的m3u8地址。或者是使用支持rtmp协议的播放器拉流。(打开软件后右键,打开,打开链接,输入地址)

    转自:https://blog.tomhuang2000.com/archives/572/

    分情破爱始乱弃,流落天涯思别离。 如花似玉负情意,影如白昼暗自迷。 随风浮沉千叶落,行色匆匆鬓已稀。
  • 相关阅读:
    SpringCloud
    SpringCloud
    一个表的字段更新另一个表的字段
    MYSQL5.7 sql_mode=only_full_group_by
    CentOS7 防火墙操作
    log4j DailyRollingFileAppender, DatePattern 配置
    Fiddler抓包-会话框添加查看get与post请求类型选项
    Fiddler抓包-工具介绍(request和response)
    Fiddler抓包-get与post请求
    Fiddler抓包-只抓APP的请求
  • 原文地址:https://www.cnblogs.com/cshaptx4869/p/15401279.html
Copyright © 2011-2022 走看看