1. 程式人生 > >nginx rtmp 環境搭建

nginx rtmp 環境搭建

環境:cetos 6.5

安裝包目錄

nginx 包下載地址: http://nginx.org/en/download.html

nginx rtmp module 包下載地址: https://github.com/arut/nginx-rtmp-module


將兩個安裝包解壓

進入nginx 解壓後的目錄

./configure  --add-module=nginx rtmp module解壓目錄 ---prefix=安裝目錄

make && make install


即將nginx rtmp 外掛安裝完成

測試config (示例) nginx.conf

worker_processes  1;
events {
    worker_connections  1024;
}

rtmp {
        access_log logs/rtmp_access.log new;

        server {
                listen 1935;
               chunk_size 4096;
                timeout    10s;
                ping 2m;
                application live {

                        live on;
                       wait_key on;
                      drop_idle_publisher 10s;

                        hls on;
                        hls_fragment 5s;
                    hls_nested on;
                        hls_sync 100ms;
                        hls_playlist_length 30s;
                        hls_path /tmp/live;
                }

    }

http {
    include       mime.types;
    default_type  application/octet-stream;

    sendfile        on;
    server {
                listen       80;
                server_name localhost;

        keepalive_timeout  65;
        location / {
                root   html;
                index  index.html index.htm;
        }
        location /crossdomain.xml{
                root html;
}
        location ~ /live/([0-9|a-z]+)/([0-9|a-z|-]+)\.m3u8 {
                root /tmp;
                add_header Cache-Control max-age=5;
                default_type  application/x-mpegURL;
            }
        location ~ /live/([0-9|a-z]+)/([0-9|a-z|-]+)\.ts {
            root /tmp;
            add_header Cache-Control max-age=5;
            default_type  video/MP2T;
        }

  }

在nginx安裝目錄下執行

./sbin/nginx -c conf/nginx.conf

即nginx rtmp 外掛啟動


測試