nginx 搭建rtmp流媒体服务器

  1. 下载PCRE 并安装.
     主页地址: ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/
  1. 解压 tar -xzvf pcre-8.40.tar.gz
     cd pcre-8.40
     make, make install (if not the root user, please use the sudo)
  1. 安装OpenSSL
     sudo apt-get install libssl-dev
  1. 下载nginx 和 nginx rtmp 模块
1: 解压 tar -zxvf nginx-1.10.0.tar.gz
       http://nginx.org/download/nginx-1.10.0.tar.gz
       git clone https://github.com/arut/nginx-rtmp-module
2: 执行nginx 编译配置
       cd  nginx-1.10.0
       ./configure --add-module=/.../nginx-rtmp-module
       make
       make install
  1. 启动nginx
      nginx 默认安装目录 /usr/local/nginx
      sbin 目录下nginx 服务器主程序, 启动 sudo ./nginx
      可能80端口被占用:

      sudo fuser -k 80/tcp
      And then try restarting nginx again:
      service nginx start
  1. 查看
     /usr/local/nginx/sbin$ ps -ef | grep nginx
        root      1394  1474  0 18:11 ?        00:00:00 nginx: master process ./nginx
        nobody    1395  1394  0 18:11 ?        00:00:00 nginx: worker process
         1570  1027  0 18:22 pts/32   00:00:00 grep --color=auto nginx
  1. 在浏览器中输入 http://localhost/ , 可以看到nginx 的首页
    (我貌似打不开, 原来是要输入服务器IP:http://172.17.6.96)
Welcome to nginx!
If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.
For online documentation and support please refer to
nginx.org.
Commercial support is available at
nginx.com.
Thank you for using nginx.
  1. 添加rtmp 支持
    sudo vi conf/nginx.conf
rtmp {
     server {
         listen 1935;
         application live {
             live on;
             record off;
         }
     }
 }

9, 重启 nginx

     cd /usr/local/nginx
     sudo ./sbin/nginx -t
     sudo ./sbin/nginx -s reload
  1. 添加测试源, 推流到服务器
 ffmpeg -re -i "http://pull3.a8.com/live/1494925686330748.flv" -c copy -f flv rtmp://172.17.6.96:1935/live/gongjia
  1. 使用vlc在局域网机器上打开rtmp测试流
rtmp://172.17.6.96:1935/live/gongjia

你可能感兴趣的:(nginx 搭建rtmp流媒体服务器)