Install Nginx with RTMP Module on CentOS

Standard

Installation process …

yum update
yum groupinstall "Development Tools"
yum install pcre-devel zlib-devel openssl-devel
yum install git
 
cd;
git clone https://github.com/arut/nginx-rtmp-module.git;
git clone https://github.com/nginx/nginx.git;
cd nginx;
./auto/configure --prefix=/etc/nginx --add-module=../nginx-rtmp-module
make;
make install;
 
useradd -r -d /var/cache/nginx/ -s /sbin/nologin -U nginx
worker_processes  1;
events {
    worker_connections  1024;
}
http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;
    server {
        listen       80;
        server_name  localhost;
        location / {
            root   html;
            index  index.html index.htm;
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
 
        location /dash {
            types {
                text/html html;
                application/dash+xml mpd;
            }
            autoindex on;
            alias /tmp/dash;
            expires -1;
 
            add_header Cache-Control no-cache;
            add_header 'Access-Control-Allow-Origin' '*';
            add_header 'Access-Control-Allow-Credentials' 'true';
            add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
            add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
        }
 
        location /hls {
            types {
                application/vnd.apple.mpegurl m3u8;
                video/mp2t ts;
            }
            autoindex on;
            alias /tmp/hls;
            expires -1;
 
            add_header Cache-Control no-cache;
            add_header 'Access-Control-Allow-Origin' '*';
            add_header 'Access-Control-Allow-Credentials' 'true';
            add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
            add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
        }
 
    }
}
 
rtmp {
#    server{
#        listen 1935;
#
#        application dash{
#            live on;
#            dash on;
#            dash_path /tmp/dash;
#            dash_fragment 15s;
#        }
#    }
 
    server {
        listen 1935;
 
        application hls {
            live on;
            hls on;
            hls_path /tmp/hls;
            hls_fragment 5s;
            hls_playlist_length 15s;
            hls_continuous on;
            hls_cleanup on;
            hls_nested on;
        }
    }
}
#test
/etc/nginx/sbin/nginx -t
#start
/etc/nginx/sbin/nginx
#stop
/etc/nginx/sbin/nginx -s stop

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.