天天看点

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;
    }

           

版权声明:本文为CSDN博主「weixin_33978016」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。

原文链接:https://blog.csdn.net/weixin_33978016/article/details/91735391