Bizarre Welten, Demo Streaming&Livestreaming-Portal

Anleitung - Eigene Video und Live Plattform erstellen

INSTALL AVideo(YouPHPTube) on Ubuntu 18.04 LTS (complete)



-----------------------------------------------
Server: 4 Kernel, 8 Gig Ram, or more, VPS oder dedicated Server)
-----------------------------------------------

Quelle / Source / Info über das System



-> Install Ubuntu 18.04 minimal (no Webserver)

1.
# apt update && apt upgrade
# apt dist-upgrade
# apt install htop mc



2.
Set Hostname:
# hostnamectl
# hostnamectl set-hostname \\'Your Hostname\\'
# mcedit /etc/hosts (edit)
# reboot
test: # hostnamectl
Test: # hostname



3.
Apache webserver:
# sudo apt install -y apache2 apache2-utils
# systemctl status apache2
# sudo systemctl start apache2
# sudo systemctl enable apache2
# apache2 -v
# sudo chown www-data:www-data /var/www/html/ -R



4.
MariaDB:
# sudo apt install mariadb-server mariadb-client
# systemctl status mariadb
# sudo systemctl start mariadb
# sudo systemctl enable mariadb
# sudo mysql_secure_installation
----------------------------
Set your MariaDB root Password and save:
MariaDB Daten:
User: root
Passwort: \\'your secure password\\'
----------------------------
Test:
# sudo mariadb -u root
# exit;
# mariadb --version



5.
PHP7.2:
# sudo apt install php7.2 libapache2-mod-php7.2 php7.2-mysql php-common php7.2-cli php7.2-common php7.2-json php7.2-opcache php7.2-readline
# sudo a2enmod php7.2
# sudo systemctl restart apache2
# php --version


# reboot



6:
YouPHPTube:
cd /var/www/html/
# sudo apt install git
# sudo git clone https://github.com/WWBN/AVideo.git
# cd AVideo/
# sudo git clone https://github.com/WWBN/AVideo-Encoder.git
# sudo mv AVideo-Encoder upload
# cd /var/www/html/
# sudo mv AVideo tube
# sudo chown www-data:www-data /var/www/html/tube/ -R



7.
Streamer & Encoder:
# sudo apt install ffmpeg
# sudo apt install libimage-exiftool-perl
# sudo apt install php7.2-cli php7.2-common php7.2-json php7.2-opcache php7.2-readline php7.2-curl php7.2-gd php7.2-xml



8.
youtube.dll:
# sudo apt install python3-pip
# sudo -H pip3 install youtube-dl
# sudo crontab -e
# @daily sudo -H pip3 install --upgrade youtube-dl > /dev/null
-----------------------------------
oder, wenn Problem:
# apt-get install python-pip
# pip install youtube-dl
----------------------------------
# service cron status
# service cron stop
# service cron start



9.
Edit MariaDB:
# sudo mcedit /etc/mysql/mariadb.conf.d/50-server.cnf

# Unter InnoDB einfügen:
# (Read the manual for more InnoDB ...)

innodb_file_format = Barracuda
innodb_file_format_max = Barracuda
innodb_file_per_table = ON
innodb_default_row_format = dynamic
innodb_large_prefix = ON

# sudo systemctl restart mariadb
Test:
# mariadb -u root
exit;



10.
Setub Database:
# mariadb -u root

Tube:
# create database Tube;
# create user Tube@localhost identified by \\'dein_passwort\\';
#### (mit denen schreiben: \\'\\')
# grant all privileges on Tube.* to Tube@localhost;

Tube-Encoder:
# create database TubeEncoder;
# create user TubeEncoder@localhost identified by \\'dein_passwort\\';
#### (mit denen schreiben: \\'\\')
# grant all privileges on TubeEncoder.* to TubeEncoder@localhost;

# flush privileges;
# exit;



11.
Apache Hosts:

your_domain.com (Server-root)
# sudo mcedit /etc/apache2/sites-available/your_domain.com.conf

    ServerName your_domain.com
    DocumentRoot /var/www/html

    
       DirectoryIndex index.html index.htm index.php
       Options +FollowSymLinks
       AllowOverride All
       Require all granted
    

    ErrorLog ${APACHE_LOG_DIR}/your_domain.com.error.log
    CustomLog ${APACHE_LOG_DIR}/your_domain.com.access.log combined



Tube Host:
# sudo mcedit /etc/apache2/sites-available/tube.conf

    ServerName www.your_domain.com
    DocumentRoot /var/www/html/tube

    
       DirectoryIndex index.php
       Options +FollowSymLinks
       AllowOverride All
       Require all granted
    

    ErrorLog ${APACHE_LOG_DIR}/tube.error.log
    CustomLog ${APACHE_LOG_DIR}/tube.access.log combined


Encoder Host:
# sudo mcedit /etc/apache2/sites-available/tube-encoder.conf

    ServerName upload.your_domain.com
    DocumentRoot /var/www/html/tube/upload

    
       DirectoryIndex index.php
       Options +FollowSymLinks
       AllowOverride All
       Require all granted
    

    ErrorLog ${APACHE_LOG_DIR}/tube-encoder.error.log
    CustomLog ${APACHE_LOG_DIR}/tube-encoder.access.log combined



# sudo a2ensite your_domain.com.conf
# sudo a2ensite tube.conf
# sudo a2ensite tube-encoder.conf

# sudo a2enmod rewrite
# sudo systemctl restart apache2

# sudo a2dissite 000-default.conf
# sudo systemctl restart apache2



12.
Cerbot:
# sudo apt install certbot
# sudo apt install python3-certbot-apache

# sudo certbot --apache --agree-tos --redirect --hsts --staple-ocsp --email your_name@hotmail.com -d yourdomain.com
# sudo certbot --apache --agree-tos --redirect --hsts --staple-ocsp --email your_name@hotmail.com -d www.yourdomain.com
# sudo certbot --apache --agree-tos --redirect --hsts --staple-ocsp --email your_name@hotmail.com -d upload.yourdomain.com



13.
Tube install:
www.your_domain.com
- follow instructions, edit php.ini.
# /etc/init.d/apache2 restart

Tube-Encoder install:
upload.yoour_domain .com
- follow instructions, edit php.ini.
# /etc/init.d/apache2 restart

-->> Check the extensions and install all database tables (red market) !



#####################################################
############## Now the Live #########################
#####################################################



14.
nginx-rtmp:
# sudo apt-get install -y build-essential libpcre3 libpcre3-dev zlib1g zlib1g-dev libssl-dev php7.2-xml
# sudo mkdir ~/build && cd ~/build && sudo git clone git://github.com/arut/nginx-rtmp-module.git
( fix: sudo git clone https://github.com/arut/nginx-rtmp-module.git )
# sudo wget http://nginx.org/download/nginx-1.16.1.tar.gz && sudo tar xzf nginx-1.16.1.tar.gz

cd nginx-1.16.1
# sudo ./configure --with-http_ssl_module --with-http_stub_status_module --add-module=../nginx-rtmp-module
# sudo make && sudo make install

# sudo mkdir /usr/local/nginx/ssl/ && sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /usr/local/nginx/ssl/nginx.key -out /usr/local/nginx/ssl/nginx.crt

# sudo /etc/init.d/apache2 restart && sudo mkdir /HLS && sudo mkdir /HLS/live

# cd /usr/local/nginx/html && wget https://youphptube.com/docs/stat.xsl
# sudo mv /usr/local/nginx/conf/nginx.conf /usr/local/nginx/conf/nginx.conf.old
# cd /usr/local/nginx/conf/ && sudo wget https://raw.githubusercontent.com/DanielnetoDotCom/YouPHPTube/master/plugin/Live/install/nginx.conf

# sudo mcedit /usr/local/nginx/conf/nginx.conf
(Save the nginx.conf and look closely !!!)
###########################################################################

    worker_processes  1;
    error_log  logs/error.log debug;
    events {
            worker_connections  1024;
    }
    rtmp {
            server {
                    listen 1935;
                    allow play all;
                    #creates our "live" full-resolution HLS videostream from our incoming encoder stream and tells where to put the HLS video manifest and video fragments
                    application live {
                            allow play all;
                            live on;
                            #record all;
                            #record_path /video_recordings;
                            #record_unique on;
                            hls on;
                            hls_nested on;
                            hls_path /HLS/live;
                            hls_playlist_length 4s;
                            #hls_fragment 1s;
                            hls_fragment 2s;
                            on_publish http://your_ip/tube/plugin/Live/on_publish.php;
                            on_publish_done http://your_ip/tube/plugin/Live/on_publish_done.php;
                            on_play http://your_ip/tube/plugin/Live/on_play.php;
                            on_record_done http://your_ip/tube/plugin/Live/on_record_done.php;
                            recorder video{
                            record all;
                            record_path /var/www/tmp;
                            record_notify on;
                            record_max_size 2048M; 
                            #will produce files of the form yourUserKey-24-Apr-13-18:23:38.flv
                            record_suffix -%d-%b-%y-%T.flv;
                        }
                    }

            }
    }
   http {
            include       mime.types;
            default_type  application/octet-stream;
            server {
                    listen 8080;
                    server_name localhost;
                    #creates the http-location for our full-resolution (desktop) HLS stream - "http://my-ip/live/my-stream-key/index.m3u8"      
                    location /live {
                            # Disable cache
                            add_header \\'Cache-Control\\' \\'no-cache\\';

                            # CORS setup
                            add_header \\'Access-Control-Allow-Origin\\' \\'*\\' always;
                            add_header \\'Access-Control-Expose-Headers\\' \\'Content-Length\\';

                            # allow CORS preflight requests
                            if ($request_method = \\'OPTIONS\\') {
                                    add_header \\'Access-Control-Allow-Origin\\' \\'*\\';
                                    add_header \\'Access-Control-Max-Age\\' 1728000;
                                    add_header \\'Content-Type\\' \\'text/plain charset=UTF-8\\';
                                    add_header \\'Content-Length\\' 0;
                                    return 204;
                            }
                            types {
                                    application/vnd.apple.mpegurl m3u8;
                            }
                            alias /HLS/live;
                    }
                    #allows us to see how stats on viewers on our Nginx site using a URL like: "http://my-ip/stats"     
                    #location /stats {
                    #        stub_status;
                    #}
                    location /stat {
                            rtmp_stat all;
                            rtmp_stat_stylesheet stat.xsl;
                    }
                    location /stat.xsl {
                            root html;
                    }
                    location /control {
                            rtmp_control all;
                    }
                    #allows us to host some webpages which can show our videos: "http://my-ip/my-page.html"     
                    location / {
                            root   html;
                            index  index.html index.htm;
                    }   
listen 444 ssl;
ssl_certificate /etc/letsencrypt/live/www.your_domain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/www.your_domain.com/privkey.pem;
            }
    }


###########################################################################
Record:
# mkdir /var/www/tmp/
# chmod: 777
# chown: www-data

# sudo mcedit /etc/apache2/mods-available/proxy.conf
inner Module:
# ProxyPass /wss/ ws://127.0.0.1:8868/

# sudo a2enmod proxy_wstunnel
# sudo systemctl restart apache2



15:
Plugins
- Install all Tables in Menue Plugins
- Live Plugin:
-> edit parameters:
Player URL :
https://www.your_domain.com:444/live
Stats Page URL :
https://www.your_domain.com:444/stat
-->> 444 !!



after each reboot you must start the nginx:
# sudo /usr/local/nginx/sbin/nginx

RTMP-Statistik:
Check, if the rtmp is runnig:
https://www.your_domain.com:444/stat