nginx-rtmp视频流服务器搭建

系统 centOS7 系统
 
用root用户登录
将目录文件拷贝到 /root 目录下

1.开放iptables  1935  1936 80 端口
 
  sudo gedit /etc/sysconfig/iptables
  增加
  -A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
  -A INPUT -p tcp -m state --state NEW -m tcp --dport 1935 -j ACCEPT
  -A INPUT -p tcp -m state --state NEW -m tcp --dport 1935 -j ACCEPT

2.安装依赖包
  yum install gcc gcc-c++ ncurses-devel perl gzip zlib pcre OpenSSL openssl-devel readline-devel perl-devel perl-ExtUtils-Embed  libxml2 libxml2-devel libxslt libxslt-devel pcre-devel
 

3.安装nginx-1.8.0

执行

  tar -zxvf /root/nginx-1.8.1.tar.gz

  cd /root/nginx-1.8.0
 
 ./configure --user=root --prefix=/root/nginx \
--with-http_stub_status_module \
--with-http_ssl_module \
--with-http_flv_module \
--with-http_mp4_module \
--with-http_xslt_module \
--with-http_perl_module \
--with-ld-opt="-Wl,-E" \
--with-mail \
--with-http_gzip_static_module \
--add-module=/root/nginx_mod_h264_streaming-2.2.7/ \
--add-module=/root/nginx-rtmp-module/


vim objs/Makefile (修改objs/Makefile文件, 去掉其中的"-Werror")

make

make install

5.启动nginx

  将目录的nginx.conf 替换 /root/nginx/conf/nginx.conf
  将目录的html替换 /root/nginx/home

  把想要播放的mp4、flv视频文件放在/root/nginx/html下
 
执行
  ./root/nginx/sbin/nginx
 
  service iptables restart

  调用  rtmp://ip:1935/vod/XXX.mp4  即可播放视频流
  调用  http:/ip:80/status    查看当前nginx请求连接数



配置防火墙方法1
// 重启防火墙
[root@localhost /]# cd /etc/sysconfig
[root@localhost /]# vim iptables
[root@localhost sysconfig]# service iptables restart


配置防火墙方法2
配置防火墙增加端口
sudo firewall-cmd --permanent --zone=public --add-port=8090/tcp
sudo firewall-cmd --permanent --zone=public --add-port=8070/tcp

重启防火墙
sudo systemctl restart firewalld

重新加载防火墙

sudo firewall-cmd --reload

代码和工具见附件

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值