一.安裝編譯時說須要的擴展php
yum install automake autoconf make gcc gcc-c++
二.安裝nginx-rtmp-modulecss
2.1第一種方式比較簡單html
yum install pcre pcre-devel yum install zlib zlib-devel yum install openssl openssl--devel
而後下載nginx,nginx-rtmp-module模塊,並解壓nginx
git clone https://github.com/arut/nginx-rtmp-module.git
由於已經安裝nginx,是一鍵安裝的c++
#進入源代碼目錄 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.confgit
說明:添加這個兩個參數 : limit_rate_after 5m; limit_rate 200k;github
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; }