野火烧不尽
春风吹又生

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

点赞
————————————————
版权声明:本文为CSDN博主「卢从利的博客」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/lu_android/article/details/80367432

赞(0)
未经允许不得转载:自由阿草 » Centos7下利用nginx, nginx-rtmp-module搭建流媒体服务器

自由阿草

联系我们联系我们