Обновляем систему:
root@tv:~# apt update
root@tv:~# apt upgraderoot@tv:~# shutdown -r now
Устанавливаем nginx:
root@tv:~# apt install nginx
mkdir -p /var/www/tv.hhbb.me/public_html
vim /etc/nginx/sites-available/tv.hhbb.me
server {
listen 80;
listen [::]:80;
root /var/www/tv.hhbb.me/public_html;
index index.html index.htm index.nginx-debian.html;
server_name tv.hhbb.me www.tv.hhbb.me;
location / {try_files $uri $uri/ =404;
}
}
раскомментировать vim /etc/nginx/nginx.conf
server_names_hash_bucket_size 64;
Активируем хост:
ln -s /etc/nginx/sites-available/tv.hhbb.me /etc/nginx/sites-enabled/
Страница приветствия:
vim /var/www/tv.hhbb.me/public_html/index.html
<html><head><title>Welcome to tv.hhbb.me!</title></head><body><h1>Success! The tv.hhbb.me server block is working!</h1></body></html>
Перезапукаем nginx:
systemctl stop nginxsystemctl start nginx
Настройка модуля трансляции:
apt install libnginx-mod-rtmp
Добавляем в конец файла:
vim /etc/nginx/nginx.conf
rtmp {
server {
listen 1935;
chunk_size 4096;
allow publish 127.0.0.1;
allow publish 178.251.106.100;
deny publish all;
application live {
live on;
record off;
hls on;
hls_path /var/www/html/stream/hls;hls_fragment 3;
hls_playlist_length 60;
dash on;dash_path /var/www/html/stream/dash;
}
}
}
systemctl reload nginx.service
Установим дополнительные утилиты:
apt install python3-pip
pip install youtube-dlyoutube-dl
Ставим ffmpeg:
apt install ffmpeg
ffmpeg -re -i video.mp4 -c:v copy -c:a aac -ar 44100 -ac 1 -f flv rtmp://localhost/live/stream
смотреть ролик здесь:
rtmp://tv.hhbb.me/live/stream
Мониторинг:
vim /etc/nginx/sites-available/rtmpserver
{
listen 8080;
server_name localhost;
# rtmp statlocation /stat {rtmp_stat all;rtmp_stat_stylesheet stat.xsl;}
location /stat.xsl {root /var/www/html/rtmp;
}
# rtmp controllocation /control {rtmp_control all;}}
server {listen 8088;location / {add_header Access-Control-Allow-Origin *;root /var/www/html/stream;}}
types {application/dash+xml mpd;}
mkdir /var/www/html/rtmpgunzip -c /usr/share/doc/libnginx-mod-rtmp/examples/stat.xsl.gz > /var/www/html/rtmp/stat.xslln -s /etc/nginx/sites-available/rtmp /etc/nginx/sites-enabled/rtmp
systemctl reload nginx.service