nginx實現 mp4流媒體服務器 原

一.安裝編譯時說需要的擴展

yum install automake autoconf make gcc gcc-c++ 

 

二.安裝nginx-rtmp-module

2.1第一種方式比較簡單

yum install pcre pcre-devel  
yum install zlib zlib-devel  
yum install openssl openssl--devel  

然後下載nginx,nginx-rtmp-module模塊,並解壓

git clone https://github.com/arut/nginx-rtmp-module.git


因爲已經安裝nginx,是一鍵安裝的

#進入源代碼目錄
cd /usr/local/lnmp-1.4/src/  

#解壓 
tar -xvf nginx-1.12.1.tar.gz

#進入解壓後的nginx 目錄

cd nginx-1.12.1

#編譯

./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_flv_module --with-http_mp4_module --with-http_gzip_static_module --with-ipv6 --with-http_sub_module --with-openssl=/usr/local/src/lnmp1.4/src/openssl-1.0.2l --with-ld-opt=-ljemalloc --add-module=/usr/local/src/nginx-rtmp-module

#安裝
make && make install

 

配置nginx.conf

說明:添加這個兩個參數 : limit_rate_after 5m;  limit_rate 200k;

server
    {
        listen 80 default_server;
        #listen [::]:80 default_server ipv6only=on;
        server_name _;
        index index.html index.htm index.php;
        root         /var/www/html/video;
        limit_rate_after 5m;
        limit_rate 100k;

        #error_page   404   /404.html;

        # Deny access to PHP files in specific directory
        #location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }

        include enable-php.conf;

        location /nginx_status
        {
            stub_status on;
            access_log   off;
        }

        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
        {
            expires      30d;
        }

        location ~ .*\.(js|css)?$
        {
            expires      12h;
        }

        location ~ /.well-known {
            allow all;
        }

        location ~ /\.
        {
            deny all;
        }

        access_log  /home/wwwlogs/access.log;
    }

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章