📜 ⬆️ ⬇️

Installing Kernel Tube Video Sharing 2.4.3 on Ubuntu 12.04

Introduction:



I'll try to share the installation of the tube script for uploading the video.

We decided not to go by writing our own script, but to use third-party solutions.

The case began back in 2010. Then we considered the existing solutions, paid and free.
Here I considered such a list like at that time. I suppose that I could not post everything then.
As a result, we stopped at Kernel Tube Video Sharing. Product paid. If you have not considered it yet, then I think you should at least glance at it and its possibilities (initially it seems to be focused on adult content).
Do not think in any way for advertising. Installation costs $ 40, maybe my post will help you save them and slightly reduce the time needed for installation :)
Now I’m working on installing KVS on the server and decided to share my instructions. On the Internet, I have not seen this.
')
Project page - www.kernel-video-sharing.com/ru
Demo site - kvs-demo.com
Demo admin - kvs-demo.com/admin

Features of our installation


1. Use suexec module mod_ruid2 - for greater security. Previously, I set everything up without it.
2. We have a KVS source package (since version 1.5) - therefore, we do not use the ionCube loader. Check this point with the developers.

Installing Kernel Tube Video Sharing 2.4.3 on Ubuntu 12.04


Server requirements

Minimum server requirements



Requirements for PHP



Recommended options (highly desirable)



Installing the necessary components



Yamdi, Imagemagick

sudo apt-get install yamdi imagemagick 

Memcache, MySQL, Apache, Php

 sudo apt-get install memcached mysql-server-5.5 apache2 libapache2-mod-rpaf php5 php5-mysql php5-curl php5-cli php5-memcache php5-gd 

Build tools

 sudo apt-get install build-essential checkinstall subversion git unzip 


Install Exim

 sudo apt-get install exim 


Exim Setup


 sudo dpkg-reconfigure exim4-config 


Nginx installation

Installing dependencies

 sudo apt-get install libssl-dev zlib1g-dev 

Download Nginx sources

 cd /usr/local/src/ wget http://nginx.org/download/nginx-1.2.4.tar.gz tar -zxvf nginx-1.2.4.tar.gz cd nginx-1.2.4 


Download additional modules

 mkdir modules # nginx-upload-progress-module git clone https://github.com/masterzen/nginx-upload-progress-module.git modules/nginx-upload-progress-module # nginx_mod_h264_streaming wget http://www.kernel-video-sharing.com/files/nginx_mod_h264_streaming-2.3.2.zip unzip nginx_mod_h264_streaming-2.3.2.zip -d modules/ rm -f nginx_mod_h264_streaming-2.3.2.zip 


Run the build configuration script

 ./configure \ --conf-path=/etc/nginx/nginx.conf \ --error-log-path=/var/log/nginx/error.log \ --pid-path=/var/run/nginx.pid \ --lock-path=/var/lock/nginx.lock \ --http-log-path=/var/log/nginx/access.log \ --http-client-body-temp-path=/var/lib/nginx/body \ --http-proxy-temp-path=/var/lib/nginx/proxy \ --http-fastcgi-temp-path=/var/lib/nginx/fastcgi \ --with-debug \ --with-http_stub_status_module \ --with-http_secure_link_module \ --with-http_gzip_static_module \ --with-http_realip_module \ --with-http_mp4_module \ --with-http_flv_module \ --with-http_ssl_module \ --with-http_dav_module \ --with-md5=/usr/lib \ --add-module=modules/nginx-upload-progress-module \ --add-module=modules/nginx_mod_h264_streaming-2.3.2 


Solution to build h264 to gcc-4.6

Re: NGINX1.0.2 + H264 streaming-2.2.7 + Fedora 15
 vi auto/cc/gcc 

 #    CFLAGS="$CFLAGS -Werror" 


We start assembly of Nginx

 make 


Run the build and install the deb package

 checkinstall --pkgname=nginx --pkgversion "1.2.4-1.relase.`date +%Y%m%d`" --backup=no --install=yes --default 


We create the user for Nginx

 sudo useradd --shell /bin/false --no-create-home nginx 


Create the necessary symlinks and folders.

 ln -s /usr/local/nginx/sbin/nginx /usr/sbin/nginx mkdir -p /var/lib/nginx/body mkdir /var/lib/nginx/proxy mkdir /var/lib/nginx/fastcgi chown -R nginx:root /var/lib/nginx/ 


Install the initialization script

 # http://wiki.nginx.org/Nginx-init-ubuntu wget http://nginx-init-ubuntu.googlecode.com/files/nginx-init-ubuntu_v2.0.0-RC2.tar.bz2 tar -jxvf nginx-init-ubuntu_v2.0.0-RC2.tar.bz2 -C /etc/init.d/ chmod 715 /etc/init.d/nginx /usr/sbin/update-rc.d -f nginx defaults rm -f nginx-init-ubuntu_v2.0.0-RC2.tar.bz2 

 vi /etc/init.d/nginx 

 DAEMON=/usr/local/nginx/sbin/nginx NGINX_CONF_FILE="/etc/nginx/nginx.conf" 


Installing video components


Installing dependencies

 # sudo apt-get -y install build-essential checkinstall git # sudo apt-get -y install libfaac-dev libjack-jackd2-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libsdl1.2-dev libtheora-dev libva-dev libvdpau-dev libvorbis-dev libx11-dev libxfixes-dev texi2html yasm zlib1g-dev libgsm1 libgsm1-dev libxvidcore4 libxvidcore-dev libdc1394-22 libdc1394-22-dev 


Install x264
Delete existing x264
 sudo apt-get remove x264 libx264-dev 

Download source x264
 cd /usr/local/src git clone git://git.videolan.org/x264.git x264_`date +"%Y%m%d"` cd x264_`date +"%Y%m%d"` 

Run the x264 build configuration script
 ./configure --enable-static 

Run the x264 assembly
 make 

Run the build and install deb package x264
 sudo checkinstall --pkgname=x264 --pkgversion="3:$(./version.sh | awk -F'[" ]' '/POINT/{print $4"+git"$5}')" --backup=no --deldoc=yes --fstrans=no --install=yes --default 


Install libvpx
Delete existing libvpx
 sudo apt-get remove libvpx-dev 

Download the libvpx sources
 cd /usr/local/src git clone http://git.chromium.org/webm/libvpx.git libvpx_`date +"%Y%m%d"` cd libvpx_`date +"%Y%m%d"` 

Run the libvpx build configuration script
 ./configure 

Run the libvpx build
 make 

Run the build and install deb package libvpx
 sudo checkinstall --pkgname=libvpx --pkgversion="1:$(date +%Y%m%d%H%M)-git" --backup=no --install=yes --deldoc=yes --fstrans=no --default 


Install ffmpeg
I installed ffmpeg 0.8.x because the versions above do not support presets and there were problems with the imposition of watermarks on the video (the syntax of the parameters in ffmpeg often changes). In version 0.8.12, everything works fine.
Delete existing ffmpeg
 sudo apt-get remove ffmpeg 

Download the source code ffmpeg
 cd /usr/local/src wget https://ffmpeg.org/releases/ffmpeg-0.8.12.tar.gz tar -zxvf ffmpeg-0.8.12.tar.gz cd ffmpeg-0.8.12 

Run the ffmpeg build configuration script
 ./configure \ --enable-gpl \ --enable-postproc \ --enable-pthreads \ --enable-swscale \ --disable-debug \ --enable-nonfree \ --enable-libopencore-amrnb \ --enable-libopencore-amrwb \ --enable-version3 \ --enable-libdc1394 \ --enable-libfaac \ --enable-libgsm \ --enable-libmp3lame \ --enable-libtheora \ --enable-libvorbis \ --enable-libx264 \ --enable-libxvid \ --enable-libvpx 

Run the ffmpeg build
 make 

Run the build and install deb package ffmpeg
 sudo checkinstall --pkgname=ffmpeg --pkgversion="0.11.1-release-`date +%Y%m%d%H%M`" --backup=no --deldoc=yes --fstrans=no --install=yes --default 


Install qt-faststart
Go to the source folder ffmpeg
 cd /usr/local/src cd ffmpeg-0.8.12 

Run the assembly qt-faststart
 make tools/qt-faststart 

Run the build and install deb package qt-faststart
 sudo checkinstall --pkgname=qt-faststart --pkgversion="$(date +%Y%m%d%H%M)-git" --backup=no --deldoc=yes --fstrans=no --default install -Dm755 tools/qt-faststart /usr/local/bin/qt-faststart 


Checking the installed video components
 x264 ffmpeg ffplay ffprobe qt-faststart 


Setting up Web servers


Create a user for the KVS website
 useradd --shell /bin/false --no-create-home www-kvs 


Create a working directory for the KVS site
 mkdir /home/kvs/ 


Apache setup
Configuring Apache Listening Ports
 vi /etc/apache2/ports.conf 

 NameVirtualHost *:8080 Listen 8080 

Install Apache Modules
 # mod_ruid2 cd /usr/local/src # wget http://mirror.pnl.gov/ubuntu/pool/universe/liba/libapache2-mod-ruid2/libapache2-mod-ruid2_0.9.7-1_amd64.deb # dpkg -i libapache2-mod-ruid2_0.9.7-1_amd64.deb 

Configuring Apache Modules
 # mod_rpaf vi /etc/apache2/mods-available/rpaf.conf 

 <IfModule rpaf_module> RPAFenable On RPAFsethostname On RPAFproxy_ips 192.168.1.2 127.0.0.1 RPAFheader X-Real-IP </IfModule> 

 # mod_ruid2 vi /etc/apache2/mods-available/ruid2.conf 

 <IfModule mod_ruid2.c> RMode config RDefaultUidGid www-data www-data RUidGid www-data www-data RGroups www-data </IfModule> 


We include the necessary Apache modules
 a2enmod rpaf a2enmod ruid2 a2enmod rewrite 


Create a folder for KVS logs
 mkdir -p /var/log/www/kvs 


Create a site for KVS in Apache
 vi /etc/apache2/sites-available/kvs.conf 


 <VirtualHost 127.0.0.1:8080> ServerAdmin admin@domain.com Servername video.domain.com ServerAlias tube.domain.com RMode config RUidGid www-kvs www-kvs RGroups www-kvs RewriteEngine on RewriteCond %{HTTP_HOST} ^tube.domain.com$ RewriteRule (.*) http://video.domain.com$1 [R=301,L] DocumentRoot /home/kvs/ # AddType text/css css php_admin_value open_basedir /home/kvs php_admin_value upload_tmp_dir /home/kvs/tmp php_admin_value session.save_path /home/kvs/tmp <Directory /home/kvs> Options -Indexes FollowSymLinks -MultiViews AllowOverride All Order allow,deny Allow from all </Directory> ErrorLog /var/log/www/kvs/kvs-apache-error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel debug CustomLog /var/log/www/kvs/kvs-apache-access.log combined </VirtualHost> 


Activate the created site
 a2ensite kvs.conf a2dissite default 


Restart Apache
 service apache2 restart 


Php Setup
Editing Php config for Apache
 vi /etc/php5/apache2/php.ini 

 register_globals = Off magic_quotes_gpc = off safe_mode = Off max_execution_time = 9999 allow_url_fopen = On file_uploads = On upload_tmp_dir = /tmp upload_max_filesize = 1024M post_max_size = 1024M memory_limit = 1024M session.gc_maxlifetime = 86400 sendmail_path = "/usr/sbin/sendmail -t -i" 


Editing Php CLI config
 vi /etc/php5/cli/php.ini 

 memory_limit = 1024M safe_mode = Off allow_url_fopen = On sendmail_path = "/usr/sbin/sendmail -t -i" 


We configure Php logging
 vi /etc/php5/apache2/php.ini 

 error_reporting = E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR display_errors = Off display_startup_errors = Off log_errors = On log_errors_max_len = 102400 error_log = /var/log/www/php.log 


Restart Apache
 service apache2 reload 


Nginx setup

The user, from under which works, nginx is placed in the group www-kvs
 usermod -a -G www-kvs nginx 


Moving the default Nginx config
 mv /etc/nginx/nginx.conf /etc/nginx/nginx.conf.bk 


Create a new Nginx config
 vi /etc/nginx/nginx.conf 

 user nginx; worker_processes 16; error_log /var/log/nginx/error.log info; #error_log logs/error.log notice; pid /var/run/nginx.pid; events { worker_connections 1024; #multi_accept on; } http { include /etc/nginx/mime.types; default_type application/octet-stream; server_tokens off; server_names_hash_bucket_size 128; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; tcp_nopush on; tcp_nodelay on; #keepalive_timeout 0; keepalive_timeout 65; gzip on; gzip_disable "MSIE [1-6]\.(?!.*SV1)"; include /etc/nginx/conf.d/*.conf; include /etc/nginx/sites-enabled/*; server { listen 192.168.1.2:80; server_name default; #charset koi8-r; #access_log logs/host.access.log main; location = /stat { stub_status on; access_log off; allow all; deny all; } location / { root html; index index.html index.htm; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } } 


Create a config for KVS
 mkdir /etc/nginx/sites-available/ mkdir /etc/nginx/sites-enabled/ vi /etc/nginx/sites-available/kvs.conf 

  upload_progress proxied 1m; proxy_buffering off; server { listen 192.168.1.3:80; server_name video.domain.com *.video.domain.com tube.domain.com ; access_log /var/log/www/kvs/kvs-nginx-access.log; error_log /var/log/www/kvs/kvs-nginx-error.log; location / { index index.php; if (-f /etc/nginx/maintenance.file) { return 503; } proxy_pass http://127.0.0.1:8080/; proxy_redirect http://video.domain.com:8080/ /; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; client_max_body_size 1024m; client_body_buffer_size 128k; proxy_connect_timeout 90; proxy_send_timeout 900; proxy_read_timeout 900; proxy_buffer_size 4k; proxy_buffers 4 32k; proxy_busy_buffers_size 64k; proxy_temp_file_write_size 64k; charset off; track_uploads proxied 30s; } location ~* ^.+\.(gif|jpg|png|mpg|mp3|mpeg|avi|ico|txt|css|js|html)$ { #valid_referers none blocked video.domain.com; #if ($invalid_referer) { # return 403; #} root /home/kvs/; expires 30d; gzip on; gzip_min_length 100; gzip_comp_level 9; gzip_types text/plain text/css text/javascript application/x-javascript; gzip_disable "MSIE [1-6]\.(?!.*SV1)"; } location ^~ /admin/include/get_upload_status.php { report_uploads proxied; } location ^~ /contents/videos/ { flv; mp4; root /home/kvs; internal; expires max; } location ^~ /contents/private/ { flv; mp4; root /home/kvs; internal; expires max; } location ^~ /contents/videos_sources/ { root /home/kvs; internal; } location ^~ /contents/albums/sources/ { root /home/kvs; internal; } # deny access to .htaccess files, if Apache's document root concurs with nginx's one # location ~ /\.ht { deny all; } } 


Activate the created site
 ln -s /etc/nginx/sites-available/kvs.conf /etc/nginx/sites-enabled/kvs.conf 


We test KVS config
 service nginx configtest 


Run Nginx
 service nginx start 


Customize KVS


Unpacking KVS content

 unzip KVS_2.4.3_20120426.zip -d /home/kvs cd /home/kvs cat /home/kvs/_INSTALL/install_EN.txt 


Create a base for KVS

 mysql -uroot -p 


 CREATE DATABASE kvs CHARACTER SET utf8 COLLATE utf8_general_ci; CREATE USER 'kvs'@'localhost' IDENTIFIED BY '*******'; GRANT ALL PRIVILEGES ON kvs.* TO 'kvs'@'localhost'; FLUSH PRIVILEGES; QUIT; 


 mysql -uroot -p kvs < _INSTALL/install_db.sql 


Rule configs KVS

 vi admin/include/setup_db.php 


 define('DB_HOST','localhost'); define('DB_LOGIN','kvs'); define('DB_PASS','*******'); define('DB_DEVICE','kvs'); 


 vi admin/include/setup_db.php 


 // a.  "/PATH"                 (, /usr/path/to/domain.com) $config['project_path']="/home/kvs"; $config['temporary_path']="/home/kvs/tmp"; $config['content_path_videos_sources']="/home/kvs/contents/videos_sources"; $config['content_path_videos_screenshots']="/home/kvs/contents/videos_screenshots"; $config['content_path_categories']="/home/kvs/contents/categories"; $config['content_path_models']="/home/kvs/contents/models"; $config['content_path_dvds']="/home/kvs/contents/dvds"; $config['content_path_avatars']="/home/kvs/contents/avatars"; $config['content_path_content_sources']="/home/kvs/contents/content_sources"; $config['content_path_advertisement']="/home/kvs/contents/advertisement"; $config['content_path_albums']="/home/kvs/contents/albums"; $config['content_path_referers']="/home/kvs/contents/referers"; $config['content_path_other']="/home/kvs/contents/other"; // // b.   $config['is_nginx']   "false",       nginx $config['is_nginx']="true"; // // c.   $config['server_type']   "apache",      apache  nginx $config['server_type']="nginx"; // // d.   $config['is_translit_directories']   "true",           $config['is_translit_directories']="true"; // // e.   $config['php_path']    php () $config['php_path']="/usr/bin/php"; // // f.   $config['ffmpeg_path']    ffmpeg () $config['ffmpeg_path']="/usr/local/bin/ffmpeg"; // // g.   $config['image_magick_path']    imagemagick () $config['image_magick_path']="/usr/bin"; // // h.   $config['mysqldump_path']     mysqldump () $config['mysqldump_path']="/usr/bin/mysqldump"; // // i.   $config['memcache_server']  $config['memcache_port'],      memcache 

See below for your configuration.

We set the rights to the KVS files

 kvsroot=/home/kvs kvsuser=www-kvs kvsgroup=www-kvs # chmod 750 $kvsroot chown -R $kvsuser:$kvsgroup $kvsroot # find $kvsroot/ -type f -exec chmod 444 {} \; find $kvsroot/ -type d -exec chmod 555 {} \; # # # 5)        777,       666: # # a. /tmp find $kvsroot/tmp -type d -exec chmod 777 {} \; find $kvsroot/tmp -type f -not -name ".htaccess" -exec chmod 666 {} \; # b. /template (  777    666     .htaccess) find $kvsroot/template -type d -exec chmod 777 {} \; find $kvsroot/template -type f -not -name ".htaccess" -exec chmod 666 {} \; # c. /contents (   /contents  , 777  ) find $kvsroot/contents -mindepth 1 -type d -exec chmod 777 {} \; find $kvsroot/contents -type f -not -name ".htaccess" -exec chmod 666 {} \; # d. /admin/smarty/cache find $kvsroot/admin/smarty/cache -type d -exec chmod 777 {} \; find $kvsroot/admin/smarty/cache -type f -not -name ".htaccess" -exec chmod 666 {} \; # e. /admin/smarty/template-c find $kvsroot/admin/smarty/template-c -type d -exec chmod 777 {} \; find $kvsroot/admin/smarty/template-c -type f -not -name ".htaccess" -exec chmod 666 {} \; # f. /admin/smarty/template-c-site find $kvsroot/admin/smarty/template-c-site -type d -exec chmod 777 {} \; find $kvsroot/admin/smarty/template-c-site -type f -not -name ".htaccess" -exec chmod 666 {} \; # g. /admin/logs (  777  ) find $kvsroot/admin/logs -type d -exec chmod 777 {} \; find $kvsroot/admin/logs -type f -not -name ".htaccess" -exec chmod 666 {} \; # h. /admin/data (   /admin/data  , 777    666     .htaccess  /admin/data/conversion/remote_cron.php) find $kvsroot/admin/data -mindepth 1 -type d -exec chmod 777 {} \; find $kvsroot/admin/data -type f -not -name ".htaccess" -not -name "remote_cron\.php" -exec chmod 666 {} \; 


Post-installation settings


Add a task to cron

 # 6)   /admin/include/cron.php       .      ,    .       : # # cd /PATH/admin/include/ && /usr/local/bin/php cron.php > /dev/null 2>&1 


 crontab -e -u www-kvs 

 */1 * * * * cd /home/kvs/admin/include/ && /usr/bin/php cron.php > /dev/null 2>&1 


Check the paths in the file admin / data / conversion / remote_cron.php

 # 8)   /admin/data/conversion/remote_cron.php     ffmpeg, yamdi  qt-faststart.     . 

 vi admin/data/conversion/remote_cron.php 

 $ffmpeg_path="/usr/local/bin/ffmpeg"; $yamdi_path="/usr/bin/yamdi"; $qtf_path="/usr/local/bin/qt-faststart"; $imagemagick_path="/usr/bin/convert"; 


Change the default admin password

 # 7)      (http://video.domain.com/admin). #    : admin / 123.       - ,         : # -   777      /admin/smarty/ (.  5d, 5e, 5f) # -     memcache,      memcache  /admin/include/setup.php (.  4i) # -           /admin/include/setup.php (.  4a) 


Go to the administrative part of the site:
video.domain.com/admin
admin: 123
  -->   -->   --> : ********** -->   


Add a conversion server

 # 9)        .     : # # : ,  Local # :  #  :  (   ) # :      /admin/data/conversion # #        ,      6  8,    . 

  -->   -->    (*):    :  .  (*): 5   :   :   (*): /home/kvs/admin/data/conversion -->   


Add a storage server

 # 10)           .   ,      embed       .           .        .                 ,       : # a.    (..       ,   KVS): # - : ,  Local # -  :  ,      # - URL: http://video.domain.com/contents/videos # -  :   ,        (nginx  apache) # -  :  # - :      /contents/videos # b.    (..      ): #           nginx.      , : video.domain.com.      , : storage.       ,       internal  nginx: # location ^~ /storage/ { # flv; # root /usr/path/to/video.domain.com/html; # internal; # } # #       /admin/tools/remote_control.php  ,          "connected": # http://video.domain.com/remote_control.php #        : # - : ,  Remote # -  :  ,      # - URL: http://video.domain.com/storage # -  : nginx # -  :   mount  FTP # - :       NFS,     NFS mount # - FTP xxx:           FTP # c. Reflected Networks CDN: # - : ,  CDN # -  :  ,      # - URL: CDN ,     Reflected Networks # -  : Reflected Networks CDN # -  :  ,     Reflected Networks # -  :   mount  FTP # - :       NFS,     NFS mount # - FTP xxx:           FTP #        ,     ,    ,        . 


   -->    -->  (*):    --> C   


   -->   -->  (*):      (*):    URL (*): http://video.domain.com/contents/videos  : Nginx (x-accel-redirect)  :   (*): /home/kvs/contents/videos -->   


Check whether everything is correctly installed and configured in KVS

 # 11)            .       .         -   . 


  -->   --> *   (   ) *    *   *      *    (   ) # *    (  ) *     -->   


We load the video and make sure that it has been successfully converted and can be viewed on the website.

 # 12)    ,       . 

  -->   --> 


Delete the _INISTALL folder

 rm -rf _INSTALL 


Next, your personal settings

Video formats, their size, the imposition of watermark, showing time-lines. All this can be customized if desired.
Read the dock and customize for yourself.

What did not like

1. There is no support for html5 - right now we are sitting here and we are trying to figure out how to show videos for Apple players and the latest androids.
2. I will replenish as memories ...

Conclusion


The instruction turned out big and a bit tedious.
I hope this post will be useful to anyone when creating a video streaming service if the choice falls on Kernel Video Sharing.

Source: https://habr.com/ru/post/151432/


All Articles