×
Community Blog How to Install ClipBucket and Nginx on CentOS 7

How to Install ClipBucket and Nginx on CentOS 7

In this tutorial, we will be installing and configuring ClipBucket and Nginx on an Alibaba Cloud Elastic Compute Service (ECS) instance with CentOS 7.

By Arslan Ud Din Shafiq, Alibaba Cloud Tech Share Author. Tech Share is Alibaba Cloud’s incentive program to encourage the sharing of technical knowledge and best practices within the cloud community.

ClipBucket is an open source media and video management system, available in both free and paid versions. With ClipBucket, you can launch your own multi-screen branded Video-On-Demand (VOD) content. ClipBucket has LDAP integration through which you can setup your Ad credentials. A revenue sharing system in ClipBucket also allows you to manage RPM (revenue per thousand impressions) by regions.

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.
In this tutorial, we will be installing and configuring ClipBucket and Nginx on an Alibaba Cloud Elastic Compute Service (ECS) instance with CentOS 7.

Prerequisites

  • You must have Alibaba Cloud Elastic Compute Service (ECS) activated and verified your valid payment method. If you are a new user, you can get a free account in your Alibaba Cloud account. If you don’t know about how to setup your ECS instance, you can refer to this tutorial or quick-start guide. Your ECS instance must have at least 1GB RAM and 1 Core processor.
  • A domain name registered from Alibaba Cloud. If you have already registered a domain from Alibaba Cloud or any other host, you can update its domain nameserver records.
  • Open port 80 and 443 for TCP connection in your security group.

Install RPMFusion Repository

For ClipBucket, you will require some backend multimedia software like FFmpeg and MP4Box. These software are needed to convert uploaded videos so they are compatible with the backend. These software are not available in Epel release or CentOS official repositories.
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

Restart your system using the following command.
 sudo yum update -y && sudo shutdown -r now

You will need to access your ECS via Putty again after restart has been completed. Remember to use your newly added username with sudo rights to log in to ECS. You will need to install unzip to unzip compressed folders. Execute the following command:
sudo yum -y install unzip

To install FFmpeg, execute the following command.
sudo yum install ffmpeg gpac -y

You will need to install Ruby to proceed. To install Ruby, first install the YAML library with the following command.
sudo yum install libyaml -y

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 latest version of RubyGems packaging program.
sudo yum install rubygems -y

Then install latest version of FLV Tool 2.
sudo gem install flvtool2

Finally, to install the 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:
To create a custom file MariaDB.repo in /etc/yum.repos.d/ directory by executing the following sed command.

sudo su -c "echo -e '[mariadb]nname = MariaDBnbaseurl = http://yum.mariadb.org/10.2/centos7-amd64ngpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDBngpgcheck=1' > /etc/yum.repos.d/MariaDB.repo"

Proceed towards MariaDB server installation by executing the command below.
sudo yum install MariaDB-server -y

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

To secure your MariaDB server, execute the command:
sudo mysql_secure_installation

The root password will be blank by default, just hit Enter to proceed and select Y and choose your password. You will be prompted with a series of questions. Accept all until you receive confirmation that you have successfully secured your MariaDB server.
Alibaba Cloud Aspara DB for RDS is a better option for database if you are planning to use this solution for your enterprise. Alibaba Cloud AsparaDB for RDS frees you from managing a database and you can focus on your business.

Install PHP and 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.
To install REMI repository, execute the following command.

sudo yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm -y

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

Create 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

Create the backup of the file php.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

Make the backup of the file www.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

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/*.confn[global]ndaemonize = yesnemergency_restart_threshold = 2nemergency_restart_interval = 1mnerror_log = /var/log/php-fpm/php-fpm-7.0-error.lognpid = /var/run/php-fpm-7.0.pidnprocess_control_timeout = 10s' > /etc/opt/remi/php70/php-fpm.conf"

Create a new file named www.conf by executing the following command.
 sudo su -c "echo -e '[www]ngroup = apachenlisten = /var/run/php-fpm-7.0.socknlisten.backlog = 65536nlisten.owner = apachenlisten.group = apachenpm = staticnpm.max_children = 2npm.max_requests = 10240nuser = apache' > /etc/opt/remi/php70/php-fpm.d/www.conf"

Create a new file named php.ini by executing the following command.
sudo su -c "echo -e '[PHP]nallow_url_fopen = Onnalways_populate_raw_post_data = -1ndisplay_errors = Offnerror_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICTnexpose_php = Offnlog_errors = Onnmax_execution_time = 7201nmemory_limit = 256Mnoutput_buffering = 4096npost_max_size = 256Mnregister_argc_argv = Offnrequest_order = "GP"nupload_max_filesize = 256Mnvariables_order = "GPCS"n[Date]ndate.timezone = America/New_Yorkn[Session]nsession.cache_limiter =nsession.gc_divisor = 1000nsession.hash_bits_per_character = 5nsession.save_handler = filesnsession.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"

Navigate to /var/log/ directory.
 cd /var/log

Create a folder / directory named php-fpm by using the command below.
 sudo mkdir php-fpm

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 Nginx Server

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

sudo yum install nginx -y

You will have to create a backup of your nginx.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

Create a new nginx.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 {ntaccess_log none;ntcharset utf-8;ntclient_body_timeout 10s;ntclient_header_timeout 10s;ntclient_max_body_size 256M;ntdefault_type application/octet-stream;ntgzip_comp_level 6;ntgzip on;ntgzip_proxied any;ntgzip_types application/json application/javascript application/x-javascript application/xml application/xml+rss text/css text/javascript text/plain text/xml;ntgzip_vary on;ntinclude /etc/nginx/mime.types;ntinclude /etc/nginx/conf.d/headers.conf;ntinclude /etc/nginx/sites-enabled/*.conf;ntindex index.html index.php;ntkeepalive_timeout 8 8;ntreset_timedout_connection on;ntsend_timeout 2s;ntsendfile on;ntserver_tokens off;nttcp_nopush on;nttcp_nodelay on;ntupstream 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, 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 headers.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"

Create a file imarslan.com.conf. Replace imarslan.com with your domain name in the command below as well as during creation of this file.

jsudo 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"

You will have to create symlink for imarslan.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 ." 

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

Get a copy of ClipBucket by executing the command.
 wget http://downloads.sourceforge.net/project/clipbucket/ClipBucket%20v2/clipbucket-2.8.v3354-stable.zip

Create a directory where do you want to place extracted files of ClipBucket.
 sudo mkdir /var/www/clipbucket

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/

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/

Create a Database

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;

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.
You have successfully installed ClipBucket. Now you can access it via your Alibaba Cloud IP address or your domain name.

Configure ClipBucket

Access ClipBucket via your Alibaba Cloud IP address or via your domain name.
Click Ok, I Agree, Now let me Continue! and then click Continue to Next Step.
In permissions, click Continue to Next Step again because we have already done permissions settings.
In database settings step, add the database credentials that you did setup.
1
Click Check Connection, your connection will be checked and you will be redirected to setup Admin credentials for ClipBucket. After adding settings, click Save and Continue.
2
Set up the title and description for your ClipBucket and then click Save and Continue.
3
Congratulations! 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 look like http://www.yourdomain.com/admin_area/login.php. Replace "yourdomain" with your actual domain name.

0 0 0
Share on

Alibaba Clouder

1,161 posts | 191 followers

You may also like

Comments