1、下载开源库

   nginx-1.9.9:  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.2o:  https://www.openssl.org/source/

2、解压开源库

    目标位置:/home/lucongli/

3、修改配置文件

     打开文件:/home/lucongli/nginx-1.9.9/auto/lib/openssl/conf

     找到修改前内容:

      CORE_INCS="$CORE_INCS$OPENSSL/.openssl/include"
      CORE_DEPS="$CORE_DEPS$OPENSSL/.openssl/include/openssl/ssl.h"
      CORE_LIBS="$CORE_LIBS$OPENSSL/.openssl/lib/libssl.a"

      CORE_LIBS="$CORE_LIBS$OPENSSL/.openssl/lib/libcrypto.a"

     修改后内容:

      CORE_INCS="$CORE_INCS$OPENSSL//include"
      CORE_DEPS="$CORE_DEPS$OPENSSL/include/openssl/ssl.h"
      CORE_LIBS="$CORE_LIBS$OPENSSL/libssl.a"

      CORE_LIBS="$CORE_LIBS$OPENSSL/libcrypto.a"

4、编译nginx-1.9.9

    # gedit /home/lucongli/nginx-Install.sh

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

保存后关闭

# cd /home/lucongli/

# chmod a+x nginx-Install.sh

# ./nginx-Install.sh

5、启动nginx

# cd /usr/local/nginx/sbin

# ./nginx

6、查看nginx端口监听情况

# netstat -ntlp

ActiveInternet connections (only servers)
Proto Recv-Q Send-Q LocalAddress          Foreign Address        State       PID/Program name   
tcp        0     0 0.0.0.0:1935           0.0.0.0:*              LISTEN      20966/nginx: master
tcp       0      0 0.0.0.0:80             0.0.0.0:*              LISTEN      20966/nginx: master

tcp       0      0 192.168.122.1:53       0.0.0.0:*              LISTEN      1384/dnsmasq       
tcp        0     0 127.0.0.1:631          0.0.0.0:*              LISTEN      1071/cupsd         
tcp        0     0 127.0.0.1:25           0.0.0.0:*              LISTEN      1445/master        
tcp6       0     0 ::1:631                :::*                   LISTEN      1071/cupsd         

tcp6      0      0 ::1:25                 :::*                   LISTEN      1445/master 


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

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

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

//重启nginx

# netstat -ntlp

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

# kill 19729

# cd /usr/local/nginx/sbin

# ./nginx

8、测试

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

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

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

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

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

相关文章: