nginx 搭建rtmp流媒体服务器

本文是搭建nginx流媒体服务器过程的笔记,方便自己或者有相关需求的人员参考。

 

注明:

主机系统:ubuntu16.04

测试主机IP:192.168.0.5

1. 下载PCRE 并安装. 

     主页地址: ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/

     该下载有点问题,这里是我已经下载好的一个文件:pcre-8.37.tar.gz

2.  解压 tar -xzvf pcre-8.37.tar.gz

     cd pcre-8.37

     ./configure

     make

     make install (if not the root user, please use the sudo)

3.  下载nginx 和 nginx rtmp 模块

     http://nginx.org/download/nginx-1.10.0.tar.gz  

     csdn资源下载:nginx-1.2.0.tar.gz

     解压 tar -zxvf nginx-1.10.0.tar.gz

     https://github.com/arut/nginx-rtmp-module

     执行nginx 编译配置

      ./configure --add-module=/path/to/nginx-rtmp-module
      make
      make install

4.   启动nginx

      sbin 目录下nginx 服务器主程序, 启动 sudo ./nginx

5.   查看

licaibiao@lcb:/usr/local/nginx/sbin$  ps -ef | grep nginx       
root      1566     1  0 17:39 ?        00:00:00 nginx: master process ./nginx
nobody    1601  1566  0 17:42 ?        00:00:00 nginx: worker process
licaibi+  1643  1314  0 18:20 pts/8    00:00:00 grep --color=auto nginx
licaibiao@lcb:/usr/local/nginx/sbin$ 
licaibiao@lcb:/usr/local/nginx/sbin$ 

6.  在浏览器中输入http://localhost/  (192.168.0.5)  , 可以看到nginx 的首页

7. 添加rtmp 支持

       sudo vi conf/nginx.conf

rtmp {
     server {
         listen 1935;
         application live {
             live on;
             record off;
         }
     }
 }

8, 重启 nginx

     sudo ./sbin/nginx -t

     sudo ./sbin/nginx -s reload

9. 添加测试源, 推流到服务器

    ffmpeg -re -i cuc_ieschool.mp4 -c copy -f flv rtmp://192.168.0.5:1935/live

10. 使用vlc在局域网机器上打开rtmp测试流

      rtmp://192.168.0.5:1935/live

    运行时如果出现错误:nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use),表示nginx已经在运行,可以使用下面命令来关闭该端口的连接

    sudo fuser -k 80/tcp

  • 0
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

li_wen01

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值