1、下载开源库

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

   <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/
<https://sourceforge.net/projects/pcre/>

   openssl-1.0.2q:  https://www.openssl.org/source/
<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

友情链接
KaDraw流程图
API参考文档
OK工具箱
云服务器优惠
阿里云优惠券
腾讯云优惠券
华为云优惠券
站点信息
问题反馈
邮箱:ixiaoyang8@qq.com
QQ群:637538335
关注微信