一.安装编译时说需要的扩展
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;
}