sudo apt-get install yamdi imagemagick
sudo apt-get install memcached mysql-server-5.5 apache2 libapache2-mod-rpaf php5 php5-mysql php5-curl php5-cli php5-memcache php5-gd
sudo apt-get install build-essential checkinstall subversion git unzip
sudo apt-get install exim
sudo dpkg-reconfigure exim4-config
sudo apt-get install libssl-dev zlib1g-dev
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
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
./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
vi auto/cc/gcc
# CFLAGS="$CFLAGS -Werror"
make
checkinstall --pkgname=nginx --pkgversion "1.2.4-1.relase.`date +%Y%m%d`" --backup=no --install=yes --default
sudo useradd --shell /bin/false --no-create-home nginx
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/
# 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"
# 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
sudo apt-get remove x264 libx264-dev
cd /usr/local/src git clone git://git.videolan.org/x264.git x264_`date +"%Y%m%d"` cd x264_`date +"%Y%m%d"`
./configure --enable-static
make
sudo checkinstall --pkgname=x264 --pkgversion="3:$(./version.sh | awk -F'[" ]' '/POINT/{print $4"+git"$5}')" --backup=no --deldoc=yes --fstrans=no --install=yes --default
sudo apt-get remove libvpx-dev
cd /usr/local/src git clone http://git.chromium.org/webm/libvpx.git libvpx_`date +"%Y%m%d"` cd libvpx_`date +"%Y%m%d"`
./configure
make
sudo checkinstall --pkgname=libvpx --pkgversion="1:$(date +%Y%m%d%H%M)-git" --backup=no --install=yes --deldoc=yes --fstrans=no --default
sudo apt-get remove 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
./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
make
sudo checkinstall --pkgname=ffmpeg --pkgversion="0.11.1-release-`date +%Y%m%d%H%M`" --backup=no --deldoc=yes --fstrans=no --install=yes --default
cd /usr/local/src cd ffmpeg-0.8.12
make tools/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
x264 ffmpeg ffplay ffprobe qt-faststart
useradd --shell /bin/false --no-create-home www-kvs
mkdir /home/kvs/
vi /etc/apache2/ports.conf
NameVirtualHost *:8080 Listen 8080
# 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
# 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>
a2enmod rpaf a2enmod ruid2 a2enmod rewrite
mkdir -p /var/log/www/kvs
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>
a2ensite kvs.conf a2dissite default
service apache2 restart
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"
vi /etc/php5/cli/php.ini
memory_limit = 1024M safe_mode = Off allow_url_fopen = On sendmail_path = "/usr/sbin/sendmail -t -i"
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
service apache2 reload
usermod -a -G www-kvs nginx
mv /etc/nginx/nginx.conf /etc/nginx/nginx.conf.bk
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; } } }
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; } }
ln -s /etc/nginx/sites-available/kvs.conf /etc/nginx/sites-enabled/kvs.conf
service nginx configtest
service nginx start
unzip KVS_2.4.3_20120426.zip -d /home/kvs cd /home/kvs cat /home/kvs/_INSTALL/install_EN.txt
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
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
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 {} \;
# 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
# 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";
# 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)
--> --> --> : ********** -->
# 9) . : # # : , Local # : # : ( ) # : /admin/data/conversion # # , 6 8, .
--> --> (*): : . (*): 5 : : (*): /home/kvs/admin/data/conversion -->
# 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 -->
# 11) . . - .
--> --> * ( ) * * * * ( ) # * ( ) * -->
# 12) , .
--> -->
rm -rf _INSTALL
Source: https://habr.com/ru/post/151432/
All Articles