码迷,mamicode.com
首页 > 其他好文 > 详细

nginx搭建直播

时间:2019-12-31 23:43:23      阅读:78      评论:0      收藏:0      [点我收藏+]

标签:live   测试   zip   root   styles   player   下载   cat   xsl   

1.搭建nginx直播 2.使用安卓推流 3.使用html播放 环境虚拟机: ip: 192.168.1.181 设置: vi /etc/sysconfig/network-script/ifcfg-ens33 IPADDR=192.168.1.181 GATEWAY=192.168.1.1 NETMASK=255.255.255.0 DNS1=192.168.1.1

1.搭建nginx直播

1-1.安装编译所需软件:

yum -y install git pcre pcre-devel zlib zlib-devel gcc openssl openssl-devel wget zip unzip

1-2.安装编译所需软件:

wget http://nginx.org/download/nginx-1.14.1.tar.gz -P /usr/local/src/
git clone git://github.com/arut/nginx-rtmp-module.git /usr/local/src/nginx-rtmp-module
tar -zxvf /usr/local/src/nginx-1.14.1.tar.gz -C /usr/local/src/
cd /usr/local/src/nginx-1.14.1/
./configure --with-http_ssl_module --add-module=../nginx-rtmp-module
make && make install

1-3.启动nginx:

/usr/local/nginx/sbin/nginx
    测试:
        浏览器访问:http://192.168.1.181

1-4.配置nginx: /usr/local/nginx/nginx.conf

http {
    ....
    server {
        listen       80;
        ....
        # rtmp stat
        location /stat {
            rtmp_stat all;
            rtmp_stat_stylesheet stat.xsl;
        }
        location /stat.xsl {
            # you can move stat.xsl to a different location
            root /usr/build/nginx-rtmp-module;
        }

        # rtmp control
        location /control {
            rtmp_control all;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
}

rtmp {
    server {
        listen 1935;
        ping 30s;
        notify_method get;

        application myapp {
            live on;
        }
    }
}

2.使用安卓推流

下载推流app,名字叫: 【i直播】

3.使用html播放

拉流地址: rtmp://192.168.1.181/myapp/mystream
播放使用: ckplayer
本地搭建web服务,将代码部署上去: 

nginx搭建直播

标签:live   测试   zip   root   styles   player   下载   cat   xsl   

原文地址:https://blog.51cto.com/3168834/2463380

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!