阿里云ECS云服务器Centos7搭建nginx +rtmp+nginx-http-flv-module 环境

阿里云ECS云服务器Centos7搭建nginx +rtmp+nginx-http-flv-module 环境

参考了caowenjing123的博客
nginx +rtmp+nginx-http-flv-module 环境搭建
进行了一些归纳整理。
以下是搭建步骤:
1./opt下创建tools文件夹,将下载的nginx-1.14.2.tar.gz放在tools文件夹中

cd /opt
mkdir tools
cd tools
wget https://nginx.org/download/nginx-1.14.2.tar.gz 

2./usr/local下创建nginx文件夹,git clone下载nginx-http-flv-module到nginx文件夹

cd /usr/local
mkdir nginx
cd nginx
git clone https://github.com/winshining/nginx-http-flv-module

3.就在tools文件夹下解压nginx-1.14.2.tar.gz,进入nginx-1.14.2目录

cd /opt/tools
tar -zxvf nginx-1.14.2.tar.gz
cd nginx-1.14.2

执行以下命令

./configure --prefix=/usr/local/nginx  --add-module=/usr/local/nginx/nginx-http-flv-module

4.执行make && make install

make && make install

5.进入 /usr/local/nginx/conf ,修改配置文件

cd /usr/local/nginx/conf
vim nginx.conf

worker_processes  10;
events {
    worker_connections  10240;
}
rtmp_auto_push on;
rtmp_auto_push_reconnect 1s;
rtmp_socket_dir /tmp;
rtmp{
        out_queue 4096;
        out_cork 8;
        max_streams 128;
        timeout 15s;
        drop_idle_publisher 15s;
        log_interval 5s;
        log_size 1m;
        server{
        	listen 1935;
         	application myapp{
                 live on;
	 			 record off;
                 gop_cache on;
          	}
         	application hls{
          		live on;
          		hls on;
          		hls_path /usr/local/nginx/html/hls;
          		hls_fragment 1s;
                hls_playlist_length 3s;
        	}
         	application dash{
           		live on;
           		dash on;
           		dash_path /usr/local/nginx/html/dash;
         	}

        }
}
http {
    	include       mime.types;
    	default_type  application/octet-stream;
    	sendfile        on;
   	 	keepalive_timeout  65;
    	server {
        	listen       8002;
        	server_name  27.94.234.228;
        	location / {
            	root   html;
            	index  index.html index.htm;
       		}
        	location /live{
                flv_live on;
                chunked_transfer_encoding  on;
                add_header 'Access-Control-Allow-Origin' '*';
                add_header 'Access-Control-Allow-Credentials' 'true';
        	}
        	location /hls{
                types {
                	application/vnd.apple.mpegurl m3u8;
					video/mp2t ts;
                 }
                 root /usr/local/nginx/html/hls;
                 add_header 'Cache-Control' 'no-cache';
        	}
         	location /dash {
            	root /usr/local/nginx/html/dash;
            	add_header 'Cache-Control' 'no-cache';
        	}

         	location /stat {
            	#configuration of push & pull status
              	rtmp_stat all;
              	rtmp_stat_stylesheet stat.xsl;
         	}
        	location /stat.xsl {
          		root /usr/local/nginx/nginx-http-flv-module;
        	}

         	location /control {
            	rtmp_control all; #configuration of control module of rtmp
			}

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

}

6.开启nginx

cd /usr/local/nginx/sbin
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

我执行完后提示进程已经在运行,就kill了一遍这个进程,然后就恢复正常了。

7.去ECS安全组添加端口1935, 8002

8.搭建成功后去浏览器输入 云服务器公用ip:8002,就有下图:
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值