下載並解壓模塊:
wget https://github.com/arut/nginx-rtmp-module/archive/master.zip unzip master.zip
停止運行的Nginx服務:
nginx -s stop
配置並編輯:
./configure --add-module=/home/nginx-rtmp-module-master
make
make install
復制Nginx:
## 路徑根據自己軟件路徑自行配置 cp /home/build/nginx-1.11.2/objs/nginx /usr/local/nginx/sbin
配置rtmp服務:
rtmp { #RTMP服務 server { listen 1935; #//服務端口 chunk_size 4096; #//數據傳輸塊的大小 application vod { play /opt/video; #//視頻文件存放位置。 } application live{ #直播開啟 live on; } } }
檢查並啟動服務:
nginx -t
nginx
另附我自己用來測試的配置文件,5個輸出
worker_processes 1;
error_log logs/error.log debug;
events {
worker_connections 1024;
}
rtmp {
server {
listen 1935;
application live1 {
live on;
}
application live2 {
live on;
}
application live3 {
live on;
}
application live4 {
live on;
}
application live5 {
live on;
}
application hls {
live on;
hls on;
hls_path temp/hls;
hls_fragment 8s;
}
}
}
http {
server {
listen 80;
location / {
root html;
}
location /stat {
rtmp_stat all;
rtmp_stat_stylesheet stat.xsl;
}
location /stat.xsl {
root html;
}
location /hls {
#server hls fragments
types{
application/vnd.apple.mpegurl m3u8;
video/mp2t ts;
}
alias temp/hls;
expires -1;
}
}
}
