MacWarrior / clipbucket-v5

Open source video hosting with PHP
Other
68 stars 45 forks source link

There must be better docu for clipbucket install #282

Closed orlovskyjavaprofi closed 8 months ago

orlovskyjavaprofi commented 11 months ago

Well i assume docu is very important its quality above all, i plan after i done with my stuff to write docu about installation. Hopefully it will not confuse people and provide clear and obvious solution to theirs problem

orlovskyjavaprofi commented 11 months ago

Here is my suggestion of installation docu:

Current development source: https://github.com/MacWarrior/clipbucket-v5

Old dev docu: https://docs.clipbucket.com/ Old video how to install clip bucket https://youtu.be/RoA2xPl0gcA

Project requirements:

Hardware

RAM : 8 GB - More! Processor : i5 2.5 + ghz base speed or more , many core atleast 4 better more!

Make sure FILES directory is writable at all times Major requirement: The minimum server requirement that we suggest for ClipBucket to run smoothly is a VPS with at least 5 GB Ram //References to other installation materials! https://github.com/MacWarrior/clipbucket-v5/blob/master/utils/install_ubuntu21.04-apache.sh

==============================================================================

Domain issues with Cloudflare

If you use Cloudflare for clipbucket, well then you need a commercial plan, free plan in cloudflare dont allow files size more then 100mb send via theirs network! If you use free of cost cloudflare plan , expect that larger files wont upload, this actually real issue if you use free cloudflare plan !

Software

Apache mod_ rewrite enabled

Mariadb 10 works the best, Mysql should work too, but you need go trough all of SQL make it Mysql native.

PHP 8.2 and higher (major)
Support for background process with Exec enabled
Supports cURL should be enabled Supports GD2 Library should be enabled Supports ImageMagick should be enabled

PHP Config


safe_mode = off output_buffering = on open_basedir = off max_execution_time = 7500 or more

memory_limit = 2000M or more session.gc_maxlifetime = 14000 or more post_max_size = 1600M or more upload_max_filesize = 1600M or more

//dont use it if you see this disable or better delete max_input_time = 3600

Other external dependencies which must be installed before clipbucket installation!

FFMPEG libx264, libfdk-aac, libmp3lame, libopus, libvpx MP4Box FFPROBE MediaInfo ImageMagick

Optional

MongoDB Elastic Search ( PHP Shield for protection of php pages, costs 199$ , i think its not required, there others option how to protect your code

§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§ Installation workflow!!!!!!! §§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§

sudo ifconfig YourETHDevice multicast where YourETHDevice your network interface!

For References if something need to be to set up! https://opensourceeducation.net/clip-bucket-2-8-on-ubuntu-14-04-with-nginx-php5-fpm-on-digitalocean-vps https://www.linode.com/docs/guides/install-php-8-for-apache-and-nginx-on-ubuntu/ https://github.com/kaoticgaming/clipbucket-v5

Inc case you need self sign certificate or use own "custom" dns C:\windows\system32\drivers\etc //this for windows users only , if you need to flush your dns https://www.digitalocean.com/community/tutorials/how-to-create-a-self-signed-ssl-certificate-for-apache-in-ubuntu-22-04

Ubuntu Upgrade always first sudo apt update && sudo apt upgrade -y Checklist Ubuntu Server upgrade to the latest LTS [ ]

Create user username [ ] https://linuxize.com/post/how-to-add-and-delete-users-on-ubuntu-20-04/ sudo adduser username sudo usermod -aG sudo username

-+-+-+-+-+-++-+ Check user access rights [ ]

//Only for reference use it with care! chown www-data:www-data -R chmod 700 -R -+-+-+-+-+-++-+

sudo groupadd webusers sudo usermod -aG webusers username sudo usermod -aG webusers www-data sudo chown -R www-data:webusers /home/username/namewherecbucket sudo chmod 770 -R /home/username/namewherecbucket sudo chown -R username:webusers /home/username/namewherecbucket/

============================================================================== (0) //For ssh [ ] sudo ufw allow ssh or sudo ufw allow 22/tcp

//For database sudo ufw allow from 127.0.0.1 to 127.0.0.1 port 3306 proto tcp

//For apache web server sudo ufw allow 80/tcp sudo ufw allow 443/tcp sudo ufw allow 443/udp

//FTP sudo ufw allow 990/tcp sudo ufw allow 40000:50000/tcp //othe useful ufw commands sudo ufw status verbose sudo ufw reload sudo ufw enable sudo ufw delete

==============================================================================

  1. Install secure FTP [ ] https://www.tecmint.com/secure-ftp-server-using-ssl-tls-on-ubuntu/ sudo apt install gnutls-bin openssl req -x509 -nodes -keyout /home/username/keystuff/ssl/private/vsftpd.pem -out /home/username/keystuff/ssl/private/vsftpd.pem -days 365 -newkey rsa:4098

    Configure Vsftpd [ ] User www-data should be allowed to read and write to username home directory directory name: domainname << ==== copy all from uploads /usr/sbin/vsftpd /etc/vsftpd.conf

sudo journalctl -u vsftpd sudo netstat -tuln


  1. SECURE SSH [ ] https://contabo.com/blog/de/ssh-keys-mit-vps-nutzen/#ueber-die-konsole

Create Firewall rules Port 80, 443 ,ssh [ ] https://www.inmotionhosting.com/support/security/open-a-port-in-ufw/


  1. Install Apache [ ] https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-on-ubuntu-22-04 Configure Apache server!

configure mod rewrite https://www.digitalocean.com/community/tutorials/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-20-04 sudo nano /etc/apache2/apache2.conf //configure your group and user aprpeatly! User myuser Group mygroup

tail /var/log/apache2/error.log


Configure GZIP compression on server (for better speed optimization) [ ]

https://ubiq.co/tech-blog/enable-gzip-compression-apache/ https://tecadmin.net/enable-gzip-compression-apache-ubuntu/


  1. Configure SSL [ ] https://www.digicert.com/kb/csr-ssl-installation/ubuntu-server-with-apache2-openssl.htm sudo a2enmod ssl apachectl configtest

// If you host not in standard apache directory well you absolutly must check and config this conf appropetly , look for directory and specifiy where it hosted! sudo nano /etc/apache2/apache2.conf

If you plan to use owncast for owncast you need to enable stufff sudo a2enmod proxy proxy_http proxy_wstunnel ssl

//Examples for Virtual hosts sudo nano /etc/apache2/sites-available/domainname.conf <VirtualHost *:443> ServerName domainname DocumentRoot /home/username/domainname

<Directory /home/username/domainname/> Options Indexes FollowSymLinks AllowOverride all Order allow,deny allow from all

    DirectoryIndex index.php
</Directory>

<Directory /home/username/domainname/admin_area> AllowOverride All Require all granted DirectoryIndex index.php

#USE SSL
SSLEngine on
SSLCertificateFile /home/username/secureloc/domainname.cert
SSLCertificateKeyFile /home/username/secureloc/domainname.key
SSLCertificateChainFile /home/username/secureloc/domainname.ca

#Setup for owncast streaming platform!
<Proxy *>
  Order deny,allow
  Allow from all
</Proxy>

ProxyRequests       Off
ProxyPreserveHost   On
AllowEncodedSlashes NoDecode

<Location /liveyourhandle>
   Order allow,deny
   Allow from all
</Location>

ProxyPass /liveyourhandle http://domainname:8080/
ProxyPassReverse /liveyourhandle http://domainname:8080/
ProxyPassMatch ^/(api|img|logo|_next|serviceWorker.js|sw.js|customjavascript|.*\.js|favicon|logo|serviceWorker.js|.*\.gif)/(.*)$ http://domainname:8080/$1/$2

# Match specific URLs and proxy them to the appropriate destination
ProxyPass /customjavascript http://domainname:8080/customjavascript
ProxyPass /sw.js http://domainname:8080/sw.js
ProxyPass /serviceWorker.js http://domainname:8080/serviceWorker.js
ProxyPass /logo http://domainname:8080/logo

# setup the proxy to forward websocket requests properly
# (note: this proxy automatically converts the secure websocket (wss)
# to a normal websocket and vice versa.
RewriteEngine On
RewriteCond %{HTTP:UPGRADE} ^WebSocket$           [NC,OR]
RewriteCond %{HTTP:CONNECTION} ^Upgrade$          [NC]
RewriteRule .* ws://127.0.0.1:8080%{REQUEST_URI}  [P,QSA,L]

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

ErrorDocument 403 /403.php
ErrorDocument 404 /404.php

AddHandler application/x-httpd-php .php .html
AddType application/x-httpd-php .php .html

#Limit max file size 1600MB
LimitRequestBody 1703936000

<VirtualHost *:80> ServerName domainname Redirect / https://domainname/


Clipbucket error and how to debug them : create this on server/upload/files/temp/development.dev

orlovskyjavaprofi commented 11 months ago

  1. Install PHP [ ] https://medium.com/@laraveltuts/how-to-install-and-run-php-8-x-on-ubuntu-20-04-8f18e7565c41 https://php.watch/articles/install-php82-ubuntu-debian PHP Extensions:

    GD Library: Used for image processing and thumbnail generation. sudo apt-get install php-gd [ ] cURL: Required for making HTTP requests and fetching remote content. sudo apt-get install php-curl [ ] Fileinfo: Helps identify the type of uploaded files. Per default installed [ ] JSON: Necessary for handling JSON data. sudo apt-get install php-json [ ] Multibyte String (mbstring): Needed for multibyte character encoding support. sudo apt-get install php-mbstring [ ] XML: Used for parsing and generating XML data. sudo apt-get install php-xml [ ] Supports GD2 Library sudo apt-get install php-gd [ ] Supports ImageMagick sudo apt-get install imagemagick [ ]

Configure PHP [ ] //check if config loaded! php --ini lookup align them to one and same values!

sudo nano /etc/php/YourPHPVersion/apache2/php.ini sudo nano /etc/php/YourPHPVersion/cli/php.ini sudo nano /etc/php/YourPHPVersion/fpm/php.ini sudo nano /etc/php/YourPHPVerions/fpm/php-fpm.conf

//old php sudo nano /etc/php/7.4/apache2/php.ini

Supports cURL [ X ] Support for background process with Exec enabled [ X ]


Reinstall Mariadb if something now working! Install Mariadb [ ] https://www.digitalocean.com/community/tutorials/how-to-install-mariadb-on-ubuntu-22-04 Create Database [ ]

//Strict DB config sudo nano /etc/mysql/my.cnf

[mysqld] sql_mode = 'NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'


  1. Install Maria DB [ X ]

sudo mysql

//Case you forgot password ALTER USER 'admin'@'localhost' IDENTIFIED WITH mysql_native_password BY 'YourNewBigPass';

mysql -u admin

Configure

SHOW PROCESSLIST;

////////////////////////////////////////////////////////////////////////////////////////////////////////////////

USE mysql; SET PASSWORD FOR 'admin'@'localhost' = PASSWORD('password for admin'); UPDATE user SET plugin='mysql_native_password' WHERE User='admin'; FLUSH PRIVILEGES; CREATE DATABASE clipbucket CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

//////////////////////////////////////////////////////////////////////////////////////////////////////////////// -- Create the user with the specified password CREATE USER 'clipadmin'@'localhost' IDENTIFIED BY 'pass for admin user';

-- Grant privileges for the user on the "clipbucket" database GRANT ALL PRIVILEGES ON clipbucket.* TO 'clipadmin'@'localhost';

-- Flush privileges to apply the changes FLUSH PRIVILEGES; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////

SHOW GRANTS FOR 'clipdmin'@'localhost';

mysql -u admin -p //Enter password: create database clipbucket; quit;

USE mysql; ALTER USER 'admin'@'localhost' IDENTIFIED BY 'your new password'; FLUSH PRIVILEGES;

Support for sending emails!

sudo apt-get install sendmail [ X ]

Current Clipbucket version 5 do not have this functionality!

==============================================================================

  1. Install external libraries [ ]

    composer for install phph external libs [ ] sudo apt install composer Install FFMPEG [ ] https://www.digitalocean.com/community/questions/how-to-install-ffmpeg sudo apt install ffmpeg libx264 [ ] sudo apt-get install libx264-dev libfdk-aac [ ] sudo apt-get install libfdk-aac-dev libmp3lame [ ] sudo apt-get install libmp3lame-dev libopus [ ] sudo apt-get install libopus-dev libvpx [ ] sudo apt-get install libvpx-dev MP4Box [ ] sudo apt-get install gpac FFPROBE [ ] already included in ffmpeg MediaInfo [ ] sudo apt-get install mediainfo mplayer [ ] sudo apt-get install mplayer mencoder [ ] sudo apt install mencoder ImageMagick [ ] sudo apt install imagemagick php7.4-dev or php8.2 for new php https://linux.how2shout.com/how-to-install-php-imagemagick-on-ubuntu-22-04/
    cURL [ ] FLVtool [ ] gem install flvtool2 openssl [ ] sudo apt-get install php-openssl check php info It should have line like that "Registered Stream Socket Transports tcp, udp, unix, udg, ssl, tls, tlsv1.0, tlsv1.1, tlsv1.2, tlsv1.3"

sudo apt-get update sudo apt-get install ruby-full sudo apt-get install rubygems GD2 [ ] sudo apt-get install libgd-dev sudo apt-get install php-imagick sudo apt-get install php-cli sudo apt-get install php-mysql

sudo add-apt-repository ppa:gpac/ppa sudo apt update sudo apt install gpac [ ]

setup of external libs

find / -name ffprobe 2>/dev/null

============================================================================== Copy clipbucket via ftp in htdocs or clone from github

Setup directory rights

chmod -R 700 * chmod -R 777 styles player chmod -R 755 cache files images includes cb_install admin_area api images js chmod -R 640 .htaccess

Files - Typically PHP files

chmod 644 403.php 404.php LICENSE ajax.php captcha.php download.php favicon.ico

// Save you current file permission, that is good , because you can easy analyze it in you favorite editor or run programm which checks if access right setup is right! sudo apt install acl getfacl -R /path/to/web-folder > permissions.txt setfacl --restore=permissions.txt

============================================================================== Finally: open the domain.name/cb_install and everything work then and only Then DO: remove cb_install directory from document root, after you complete with install

Minor note for dev and customization: clipbucket functions.php contains very important functions like mail validation and etc

dbclass in clipbucket //echo "Debugging SQL Query: $query"; for seeing query

In case you need to add lib to clipbucket via composer composer update this is needed when you change composer.json of clipbucket project

composer require smarty/smarty:3.1.48 --ignore-platform-req=php composer remove smarty/smarty

============================================================================== Here is Installation end for Clipbucket, but if you like integrated opensource project owncast, live stream , then you can easy do it.

Now proceed with owncast.com https://owncast.online/quickstart/manual/

  1. sudo ufw allow 8080/tcp
  2. start services ./owncast
  3. http://ipadress:8080/admin and default pass abc123 (after that setup longer and more secure pass)

https://linuxize.com/post/how-to-unzip-files-in-linux/

SSL https://owncast.online/docs/sslproxies/apache/

OWNCAST WIDGET: { Message } {include file="$style_dir/message.html"} {if $currentPage neq 'upload'}


Live stream !

// this orginal code other for clipbucke integration
                {/if}

==============================================================================

MacWarrior commented 8 months ago

Hello @orlovskyjavaprofi,

You got the point, CB5 miss documentation, but many things aren't totally correct here... Don't forget that ChatGPT can't replace real developers and is stuck in 2021 ; it also can't differency Clipbucket original and ClipbucketV5 which is relatively... different 😉

Proper documentation will be written when we'll have time for that, in Github Wiki 😇 Until then, the most relevant and updated documentation would be installation scripts (Debian12 in particular, which has been recently updated)

Thanks again for your participation, Best regards, MacWarrior.