Centos7下利用nginx, nginx-rtmp-module搭建流媒体服务器

1、下载开源库

   nginx-1.15.7:  http://nginx.org/download/

   nginx-rtmp-module: 

                 # cd /home/lucongli/

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

   pcre-8.42:  https://sourceforge.net/projects/pcre/

   openssl-1.0.2q:  https://www.openssl.org/source/

2、解压开源库

    目标位置:/root

3、编译nginx-1.15.7

# gedit /root/nginx-Install.sh  

#!/bin/bash
echo "install nginx!"

cd /usr/local/
if [ -d "nginx" ];
then
rm -rf nginx
fi
mkdir nginx

cd /root/nginx-1.15.7
chmod a+x configure
./configure \
--with-pcre=/root/pcre-8.42 \
--with-openssl=/root/openssl-1.0.2q \
--add-module=/root/nginx-rtmp-module \
--prefix=/usr/local/nginx

make -j 8 install
chmod -R 777 /usr/local/nginx

保存后关闭

# cd /root

# chmod a+x nginx-Install.sh

# ./nginx-Install.sh

4、启动nginx

# cd /usr/local/nginx/sbin

# ./nginx

5、查看nginx端口监听情况

# netstat -ntlp

6、编辑nginx.conf让其具有直播、点播、转发rtmp流能力

# gedit /usr/local/nginx/conf/nginx.conf

添加如下内容:

rtmp{
     server{
          listen 1935;
        chunk_size 4096;

          application live{
         live on;
         }

          application vod{
              play /usr/local/nginx/html/;
             }
 
          application remote{
          live on;
          pull rtmp://live.hkstv.hk.lxdns.com/live/hks;
             }
      }
}

//重启nginx

# kill 9702

# cd /usr/local/nginx/sbin

# ./nginx

# netstat -ntlp

7、测试

直播推流地址:rtmp://localhost/live/dahua.flv

        观看地址:rtmp://localhost/live/dahua

点播观看地址:rtmp://localhost/vod/friends

         //点播需要事先将friends.flv存放到目录:/usr/local/nginx/html

远程rtmp公测观看地址:rtmp://localhost/remote

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值