ClipBucket – installation of ClipBucket and Nginx LEMP on CentOS

ClipBucket is an open source media and video management system, available as free version as well as paid version. With ClipBucket, you can lunch your own multi-screen branded Video-On-Demand (VOD). A revenue sharing system in ClipBucket allows you to manage RPM by regions. You can go live with ClipBucket.

ClipBucket has LDAP integration through which you can setup your Ad credentials. ClipBucket allows you to show pre-roll, midroll and post-roll ads. ClipBucket provides you to see statistics and reports. It supports adaptive streaming which can be switched from Admin panel. It provides content security where only authorized users can watch videos. iOS and Android apps are available for your ClipBucket platform.

Operating System:

ClipBucket does not restrict its installation to any specific operating system (OS). You can use any operating system (OS) of your choice; however, the installation steps would vary according to the choice of operating system.

Prerequisites:

  1. VPS must have at least 1GB RAM and 1 Core processor.
  2. A registered domain name.
  3. You should setup your VPS’s hostname.

Getting started:

After completing the prerequisites, login as root user with your root username & password via SSH client (e.g. Putty – You can get Putty from https://www.putty.org )

Add a User with Root Privileges:

In the first step, you will add a new user and give it sudo privileges. Sudo privileges will allow this username to make administrative changes on system when required. This user will be used to login from via SSH for everyday use. Once you have added this user, to keep your server secure from various attacks, you will disable the remote root access to root user.

  1. To create a new user account, use the following command:
# adduser aareez

where “aareez” can be any username of your choice.

  1. Now you will need to set password for your added username. To set password, execute the following commands:
# passwd aareez

Now set your desired password and retype your desired password, then hit Enter key. To confirm the data is correct, type ‘Y’ and hit Enter key.

  1. Now assign username to sudo user’s group to give administrative privileges. For this, we will check /etc/sudoers file and see whether sudoers group is enabled or not. For this purpose, we will execute the following command.
# visudo
  1. After executing the above command, a file will be opened, find the following lines in the opened file.

couch cms clipbucket

Sometimes by default the second line %wheel    ALL=(ALL:ALL)    ALL is commented (starting with hash #), due to which even after adding username to sudoers, it gives error on using sudo. To prevent this issue, if this line starts with ‘#’ sign, remove this symbol and save the changes by pressing Esc key, type 😡 and hit enter.

  1. Now you will add your username “aareez” to the “wheel” group by executing the following command:
# usermod -aG wheel aareez

After execution of the above command, you can verify the membership for that group by executing the following command:

# groups aareez

Your username has been successfully added to sudoers group and it is able to execute any root command.

  1. Now, log in by using your new username and password. OR Use the following command to switch user:
# su - aareez

You can see that you have been logged in from your new account now. If you want to verify this, you can use the command below:

# whoami

 

Update your CentOS 7 System:

Before proceeding with installation of any kind of package, use the following command to update your CentOS system. To execute this command, remember to login from non-root user with sudo privileges.

  1. First clear cache by executing following command:
# sudo yum clean all
  1. Install datarpm Delta RPM packages are smaller in size than patch RPMs. But it takes more CPU utilization.
# sudo yum install deltarpm -y
  1. Now update system.
# sudo yum -y update

 

Install RPMFusion Repository

For ClipBucket, you will require some backend multimedia software like FFmpeg and MP4Box. These software are not available in Epel release or CentOS official repositories.

  1. To install RPMFusion Repository, execute the following command.
# sudo yum localinstall --nogpgcheck https://download1.rpmfusion.org/free/el/rpmfusion-free-release-7.noarch.rpm -y
  1. Now to perform the system update, restart your system using the following command.
# sudo yum update -y && sudo shutdown -r now
  1. Now you will need to access your ECS via Putty again after restart has been completed.
  2.  Remember to use your newly added username with sudo rights to log in to ECS.
  3. Now you have successfully updated your CentOS system.

Install unzip:

You will need to install unzip to unzip compressed folders.

Execute the following command:

# sudo yum -y install unzip

 Install the Backend Multimedia Software for ClipBucket:

ClipBucket requires installation of some modules to convert uploaded videos to convert and make them compatible with web in backend. For this, you will need to install FFmpeg and MP4Box (part of GPAC).

Install FFmpeg and MP4Box:

To install ffmpeg, execute the following command.

# sudo yum install ffmpeg gpac -y

Install libyaml:

To install the Ruby, YAML library is required. To install YAML library, execute the following command.

# sudo yum install libyaml -y

Install Ruby:

To install latest version of Ruby, execute the following command.

# sudo rpm -ivh https://github.com/feedforce/ruby-rpm/releases/download/2.5.0/ruby-2.5.0-1.el7.centos.x86_64.rpm

Install Ruby Gems:

To install latest version of RubyGems packaging program, execute the following command.

# sudo yum install rubygems -y

Install FLV Tool 2:

To install latest version of FLV Tool 2, execute the following command.

# sudo gem install flvtool2

Install ImageMagick, Mediainfo and MPlayer:

  1. To install latest version of MPlayer, Mediainfo and ImageMagick, execute the following command.
# sudo yum install ImageMagick mediainfo mplayer -y

Install MariaDB Server:

CentOS has MariaDB by default. The version for Maria DB by default is 5.5.x available in default repository in CentOS. In order to install latest version of MariaDB server, you will be required to add MariaDB RPM repository. For latest version, follow the steps:

  1. To create a custom file repo in /etc/yum.repos.d/ directory by executing the following sed command.
# sudo su -c "echo -e '[mariadb]\nname = MariaDB\nbaseurl = http://yum.mariadb.org/10.2/centos7-amd64\ngpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB\ngpgcheck=1' > /etc/yum.repos.d/MariaDB.repo"
  1. Now proceed towards installation of MariaDB server by executing the command below.
# sudo yum install MariaDB-server -y
  1. Execute the following command to enable and start MariaDB server so that it may automatically start when system is rebooted.
# sudo systemctl start mariadb
# sudo systemctl enable mariadb
  1. Now to secure your MariaDB server, execute the command:
# sudo mysql_secure_installation

The root password will be blank by default, just hit enter button to proceed and select ‘Y’ and choose your password.

  1. Type Y for removing anonymous users and hit Enter
  2. Type Y for Disallow root login remotely? And hit Enter
  3. Type Y for Remove test database and access to it? And hit Enter
  4. Type Y for Reload privilege tables now? And hit Enter
  5. You have successfully secured your MariaDB server.

Install PHP and its required extensions:

You will need to install and configure PHP-FPM daemon to process PHP. For installation of new version of PHP-FPM, REMI repository would be required. Follow the steps below to achieve the required things.

  1. To install REMI repository, execute the following command.
# sudo yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm -y
  1. To install the required extensions of PHP, execute the following command.
# sudo yum install php70-php-cli php70-php-pecl-imagick php70-php-fpm php70-php-mysql php70-php-opcache -y
  1. Now make the backup of the file php-fpm.conf in directory /etc/opt/remi/php70/ and rename it to php-fpm.conf.real by executing the command below.
# sudo mv /etc/opt/remi/php70/php-fpm.conf /etc/opt/remi/php70/php-fpm.conf.real
  1. Now make the backup of the file ini in directory /etc/opt/remi/php70/ and rename it to php.ini.real by executing the command below.
# sudo mv /etc/opt/remi/php70/php.ini /etc/opt/remi/php70/php.ini.real
  1. Now make the backup of the file conf in directory /etc/opt/remi/php70/php-fpm.d/ and rename it to www.conf.real by executing the command below.
# sudo mv /etc/opt/remi/php70/php-fpm.d/www.conf /etc/opt/remi/php70/php-fpm.d/www.conf.real
  1. Now create a new file named php-fpm.conf by executing the command below.
# sudo su -c "echo -e 'include=/etc/opt/remi/php70/php-fpm.d/*.conf\n[global]\ndaemonize = yes\nemergency_restart_threshold = 2\nemergency_restart_interval = 1m\nerror_log = /var/log/php-fpm/php-fpm-7.0-error.log\npid = /var/run/php-fpm-7.0.pid\nprocess_control_timeout = 10s' > /etc/opt/remi/php70/php-fpm.conf"
  1. Now create a new file named conf by executing the following command.
# sudo su -c "echo -e '[www]\ngroup = apache\nlisten = /var/run/php-fpm-7.0.sock\nlisten.backlog = 65536\nlisten.owner = apache\nlisten.group = apache\npm = static\npm.max_children = 2\npm.max_requests = 10240\nuser = apache' > /etc/opt/remi/php70/php-fpm.d/www.conf"
  1. Now create a new file named ini by executing the following command.
# sudo su -c "echo -e '[PHP]\nallow_url_fopen = On\nalways_populate_raw_post_data = -1\ndisplay_errors = Off\nerror_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT\nexpose_php = Off\nlog_errors = On\nmax_execution_time = 7201\nmemory_limit = 256M\noutput_buffering = 4096\npost_max_size = 256M\nregister_argc_argv = Off\nrequest_order = \"GP\"\nupload_max_filesize = 256M\nvariables_order = \"GPCS\"\n[Date]\ndate.timezone = America/New_York\n[Session]\nsession.cache_limiter =\nsession.gc_divisor = 1000\nsession.hash_bits_per_character = 5\nsession.save_handler = files\nsession.save_path = \"/var/opt/remi/php70/lib/php/session/\"\nurl_rewriter.tags = \"a=href,area=href,frame=src,input=src,form=fakeentry\"' > /etc/opt/remi/php70/php.ini"
  1. Now navigate to /var/log/
# cd /var/log
  1. Create a folder / directory named php-fpm by using the command below.
# sudo mkdir php-fpm
  1. Now start php-fpm server and enable it to start it automatically after reboot.
# sudo systemctl enable php70-php-fpm
# sudo systemctl start php70-php-fpm

 

Install & configure Nginx server:

To install the latest version of Nginx Web Server, you will need to execute the following command.

# sudo yum install nginx -y

Now you will have to create a backup of your conf file and rename it. You can locate this file in /etc/nginx directory. To backup and rename it to nginx.conf.real, execute the command below.

# sudo mv /etc/nginx/nginx.conf /etc/nginx/nginx.conf.real

Now you will create new conf file, to do so, just copy and execute the command below.

# sudo su -c "echo -e 'error_log /var/log/nginx/error_log info;\nevents { multi_accept on; worker_connections 1024; }\nhttp {\n\taccess_log none;\n\tcharset utf-8;\n\tclient_body_timeout 10s;\n\tclient_header_timeout 10s;\n\tclient_max_body_size 256M;\n\tdefault_type application/octet-stream;\n\tgzip_comp_level 6;\n\tgzip on;\n\tgzip_proxied any;\n\tgzip_types application/json application/javascript application/x-javascript application/xml application/xml+rss text/css text/javascript text/plain text/xml;\n\tgzip_vary on;\n\tinclude /etc/nginx/mime.types;\n\tinclude /etc/nginx/conf.d/headers.conf;\n\tinclude /etc/nginx/sites-enabled/*.conf;\n\tindex index.html index.php;\n\tkeepalive_timeout 8 8;\n\treset_timedout_connection on;\n\tsend_timeout 2s;\n\tsendfile on;\n\tserver_tokens off;\n\ttcp_nopush on;\n\ttcp_nodelay on;\n\tupstream php-7.0 { server unix:/var/run/php-fpm-7.0.sock; }\n}\nuser apache apache;\nworker_processes auto;' > /etc/nginx/nginx.conf"

In /etc/nginx directory, now create directories for site-enabled and site-available by executing command.

# sudo mkdir /etc/nginx/{sites-available,sites-enabled}

To prevent from XSS exploitation, click jacking, sniffing etc, and from access of hidden and sensitive files like git, .htaccess, you will need to create few files conf, expires.conf and deny-log-not-found.conf in directory /etc/nginx/conf.d. expires.conf will set expiry time for static content. To do so, execute the command below.

# sudo su -c "echo -e 'location ~ /\. { deny all; }\nlocation = /(favicon.ico|robots.txt) { log_not_found off; }' > /etc/nginx/conf.d/deny-log-not-found.conf" && sudo su -c "echo -e 'location ~* ^.+\.(atom|bmp|bz2|css|doc|eot|exe|gif|gz|ico|jpeg|jpg|js|mid|midi|mp4|ogg|ogv|otf|pdf|png|ppt|rss|rft|svg|svgz|tar|tgz|ttf|wav|woff|woff2|xls|zip)$ { expires max; log_not_found off; }' > /etc/nginx/conf.d/expires.conf" && sudo su -c "echo -e 'add_header X-Content-Type-Options \"nosniff\";\nadd_header X-Frame-Options \"SAMEORIGIN\";\nadd_header X-Robots-Tag \"noarchive,noodp,noydir\";\nadd_header X-Xss-Protection \"1; mode=block\";' > /etc/nginx/conf.d/headers.conf"
  1. Now create a file com.conf. Replace imarslan.com with your domain name in the command below as well as during creation of this file.
 

sudo su -c “echo -e ‘server {\n\tinclude /etc/nginx/conf.d/deny-log-not-found.conf;\n\tinclude /etc/nginx/conf.d/expires.conf;\n\tindex index.php;\n\tlocation / {\n\t\ttry_files \$uri \$uri/ /index.php;\n\t\trewrite ^/(.*)v([0-9]+) /watchvideo.php?v=\$2&\$query_string;\n\t\trewrite ^/([a-zA-Z0-9-]+)/?\$ /view_channel.php?uid=\$1&seo_diret=yes;\n\t\t}\n\tlocation ~ \.php\$ { fastcgi_pass php-7.0; include /etc/nginx/fastcgi.conf; }\n\tlocation /categories {\n\t\trewrite ^/categories/?\$ /categories.php;\n\t\t}\n\tlocation /channel {\n\t\trewrite ^/channel/(.*) /view_channel.php?user=\$1;\n\t\t}\n\tlocation /channels {\n\t\trewrite ^/channels/(.)/(.)/(.)/(.)/(.*) /channels.php?cat=\$1&sort=\$3&time=\$4&page=\$5&seo_cat_name=\$2;\n\t\trewrite ^/channels/([0-9]+) /channels.php?page=\$1;\n\t\trewrite ^/channels/?\$ /channels.php;\n\t\t}\n\tlocation /collection {\n\t\trewrite ^/collection/(.)/(.)/(.*) /view_collection.php?cid=\$1&type=\$2&\$query_string;\n\t\t}\n\tlocation /collections {\n\t\trewrite ^/collections/(.)/(.)/(.)/(.)/(.*) /collections.php?cat=\$1&sort=\$3&time=\$4&page=\$5&seo_cat_name=\$2;\n\t\trewrite ^/collections/([0-9]+) /collections.php?page=\$1;\n\t\trewrite ^/collections/?\$ /collections.php;\n\t\t}\n\tlocation /contact {\n\t\trewrite ^/contact/?\$ /contact.php;\n\t\t}\n\tlocation /create_group {\n\t\trewrite ^/create_group /create_group.php;\n\t\t}\n\tlocation /group {\n\t\trewrite ^/group/([a-zA-Z0-9].+) /view_group.php?url=\$1&\$query_string;\n\t\t}\n\tlocation /groups {\n\t\trewrite ^/groups/(.)/(.)/(.)/(.)/(.*) /groups.php?cat=\$1&sort=\$3&time=\$4&page=\$5&seo_cat_name=\$2; rewrite ^/groups/([0-9]+) /groups.php?page=\$1;\n\t\trewrite ^/groups/?\$ /groups.php;\n\t\t}\n\tlocation /item {\n\t\trewrite ^/item/(.)/(.)/(.)/(.) /view_item.php?item=\$3&type=\$1&collection=\$2;\n\t\t}\n\tlocation /members {\n\t\trewrite ^/members/?\$ /channels.php;\n\t\t}\n\tlocation /my_account {\n\t\trewrite ^/my_account /myaccount.php;\n\t\t}\n\tlocation /page {\n\t\trewrite ^/page/([0-9]+)/(.*) /view_page.php?pid=\$1;\n\t\t}\n\tlocation /photo_upload {\n\t\trewrite ^/photo_upload/(.*) /photo_upload.php?collection=\$1;\n\t\trewrite ^/photo_upload/?\$ /photo_upload.php;\n\t\t}\n\tlocation /photos {\n\t\trewrite ^/photos/(.)/(.)/(.)/(.)/(.*) /photos.php?cat=\$1&sort=\$3&time=\$4&page=\$5&seo_cat_name=\$2;\n\t\trewrite ^/photos/([0-9]+) /photos.php?page=\$1;\n\t\trewrite ^/photos/?\$ /photos.php;\n\t\t}\n\tlocation = /rss {\n\t\trewrite ^(.*)\$ /rss.php;\n\t\t}\n\tlocation /rss {\n\t\trewrite ^/rss/([a-zA-Z0-9].+)\$ /rss.php?mode=\$1&\$query_string;\n\t\t}\n\tlocation /search {\n\t\trewrite ^/search/result/?\$ /search_result.php;\n\t\t}\n\tlocation /signup {\n\t\trewrite ^/signup/?\$ /signup.php;\n\t\t}\n\tlocation = /sitemap.xml {\n\t\trewrite ^(.*)\$ /sitemap.php;\n\t\t}\n\tlocation /upload {\n\t\trewrite ^/upload/?\$ /upload.php;\n\t\t}\n\tlocation /user {\n\t\trewrite ^/user/(.*) /view_channel.php?user=\$1;\n\t\t}\n\tlocation /users {\n\t\trewrite ^/users/?\$ /channels.php;\n\t\t}\n\tlocation /video {\n\t\trewrite ^/video/(.)/(.) /watch_video.php?v=\$1&\$query_string; rewrite ^/video/([0-9]+)(.*) /watchvideo.php?v=\$1&\$query_string;\n\t\t}\n\tlocation /videos {\n\t\trewrite ^/videos/(.)/(.)/(.)/(.)/(.*) /videos.php?cat=\$1&sort=\$3&time=\$4&page=\$5&seo_cat_name=\$2;\n\t\trewrite ^/videos/([0-9]+) /videos.php?page=\$1;\n\t\trewrite ^/videos/?\$ /videos.php?\$query_string;\n\t\t}\n\tlocation /view_topic {\n\t\trewrite ^/view_topic/([a-zA-Z0-9].+)tid([0-9]+) /view_topic.php?tid=\$2&\$query_string;\n\t\t}\n\tserver_name imarslan.com www.imarslan.com;\n\troot /var/www/html;\n}’ > /etc/nginx/sites-available/imarslan.com.conf”

 

 

Now you will have to create symlink for com.conf file in /etc/nginx/sites-enabled/ from /etc/nginx/sites-available/. To do so, execute the command below. 

Remember to change imarslan.com with your domain name.

# sudo su -c "cd /etc/nginx/sites-enabled && ln -s ../sites-available/imarslan.com.conf ."
  1. Now enable and start your Nginx server so that it may start automatically, when your system reboot.
# sudo systemctl enable nginx && sudo systemctl start nginx

Install ClipBucket:

To install ClipBucket, navigate to directory cd /tmp/ 

# cd /tmp

Now get copy of ClipBucket by executing the command.

# wget http://downloads.sourceforge.net/project/clipbucket/ClipBucket%20v2/clipbucket-2.8.v3354-stable.zip

Now create directory where do you want to place extracted files of ClipBucket.

# sudo mkdir /var/www/clipbucket

Now execute the command below to copy required files in /var/www/clipbucket

# sudo cp -r /tmp/clipbucket-2.8.v3354-stable/upload/* /var/www/clipbucket/
# sudo cp /tmp/clipbucket-2.8.v3354-stable/upload/.htaccess /var/www/clipbucket/

 

Permissions Settings:

To give the necessary permissions, execute the commands below:

# sudo chmod -R 777 /var/www/clipbucket/includes/
# sudo chmod -R 777 /var/www/clipbucket/files/
# sudo chmod -R 777 /var/www/clipbucket/images/
# sudo chmod -R 777 /var/www/clipbucket/cache/
# sudo chmod -R 777 /var/www/clipbucket/cb_install/
# sudo chown apache:apache -R /var/www/clipbucket/

Database Creation:

Execute the command below to access your MariaDB server. Then you will asked to enter your password, enter your selected password and hit Enter

# mysql -u root -p

Execute the following query to create table and assign user to database.

CREATE DATABASE cbdb;
CREATE USER 'cbdb'@'localhost' IDENTIFIED BY 'Password';
GRANT ALL PRIVILEGES ON cbdb.* TO 'cbdb'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Now you have successfully assigned user to your database. You can change cbdb to your desired database name and username and set password of your choice in place of Password.

Congratulations! You have successfully installed ClipBucket. You can access it via your Alibaba Cloud IP address or your domain name.

ClipBucket Configurations:

Access ClipBucket via your Alibaba Cloud IP address or via your domain name. You will see the following page. Click Ok, I Agree, Now let me Continue! Button

clipbucket

In precheck step, click Continue to Next Step

clipbucket

In permissions step, again click Continue to Next Step button because we have already done permissions settings.

clipbucket

In database settings step, add database credentials that you did setup. According to my values, I have added screenshot below.

clipbucket

Click Check Connection button, your connection will be checked and you will be redirected to setup Admin credentials for ClipBucket. After adding settings, click Save and Continue button.

clipbucket

Do setup title and sub title for your ClipBucket and then click Save and Continue button.

clipbucket

Now you have successfully configured ClipBucket. You can access your Admin Area from here and you can access website from your domain. Link to admin area will be like http://www.yourdomain.com/admin_area/login.php

Here you go, you have successfully installed and configured your ClipBucket, now you can enter in market easily. Good Luck!

Leave a Reply

Your email address will not be published. Required fields are marked *