centos7 流服务器搭建

自动搭建流服务器的脚本

yum install git
yum -y install gcc gcc-c++
yum install -y pcre pcre-devel
yum install -y zlib zlib-devel
yum install -y openssl openssl-devel
wget https://nginx.org/download/nginx-1.15.8.tar.gz
git clone https://github.com/arut/nginx-rtmp-module.git
tar -xvf nginx-1.15.8.tar.gz
cd nginx-1.15.8
./configure --prefix=/usr/local/nginx --add-module=…/nginx-rtmp-module --with-http_ssl_module
make
make install


一. gcc 安装
安装 nginx 需要先将官网下载的源码进行编译,编译依赖 gcc 环境,如果没有 gcc 环境,则需要安装:

yum -y install gcc gcc-c++

二. PCRE pcre-devel 安装

PCRE(Perl Compatible Regular Expressions) 是一个Perl库,包括 perl 兼容的正则表达式库。nginx 的 http 模块使用 pcre 来解析正则表达式,所以需要在 linux 上安装 pcre 库,pcre-devel 是使用 pcre 开发的一个二次开发库。nginx也需要此库。命令:

yum install -y pcre pcre-devel

三. zlib 安装

zlib 库提供了很多种压缩和解压缩的方式, nginx 使用 zlib 对 http 包的内容进行 gzip ,所以需要在 Centos 上安装 zlib 库。

yum install -y zlib zlib-devel

四. OpenSSL 安装

OpenSSL 是一个强大的安全套接字层密码库,囊括主要的密码算法、常用的密钥和证书封装管理功能及 SSL 协议,并提供丰富的应用程序供测试或其它目的使用。nginx 不仅支持 http 协议,还支持 https(即在ssl协议上传输http),所以需要在 Centos 安装 OpenSSL 库。

yum install -y openssl openssl-devel

五、安装nginx 跟rtmp模块

1.官网下载直接下载.tar.gz安装包,地址:https://nginx.org/en/download.html
wget https://nginx.org/download/nginx-1.15.8.tar.gz

2.解压

tar -zxvf nginx-1.13.8.tar.gz

  1. 下载rtmp 模块, nginx-rtmp-module的官方github地址:https://github.com/arut/nginx-rtmp-module
    git clone https://github.com/arut/nginx-rtmp-module.git
  2. 安装nginx跟rtmp模块

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

make & make install

6.修改配置文件。进入 /usr/local/nginx/conf 文件夹。增添rtmp部分
/usr/local/nginx/conf/nginx.conf

rtmp {      
    server {   
        listen 1935;  #监听的端口
        chunk_size 4000;     
        application hls {  #rtmp推流请求路径
            live on;     
        }   
    }   
}

7.重启电脑。进入 /usr/local/nginx/sbin文件夹,执行./nginx启动nginx
六、OBS推流
1.设置推流地址

rtmp://192.168.1.38:1935/hls
流名称:test
这里说明下,rtmp的URL基础格式 rtmp://nginx_host[:nginx_port]/application_name/stream_name

2.推流

媒体源添加摄像机地址。然后点击推流。

3.vlc串流地址输入rtmp://192.168.1.39:1935/hls/test

https://my.oschina.net/u/188924/blog/3003042

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值