You are here: Home / Debian GNU/Linux / Web applications / Files management / Install Open Upload file sharing tool on Debian

Install Open Upload file sharing tool on Debian

by Pierre-Yves Landuré last modified May 05, 2014 10:47

Open Upload is a free software clone of sharing sites like MegaUpload, Rapidshare, Mediafire, YouSendIt, etc... It ease the exchange of big files. It is very useful as an alternative to exchanging files by e-mail.

This howto is tested on :

  • Debian 6.0 Squeeze

This howto is tested with these versions of Open Upload :

  • 0.4.2

Prerequisites

This howto needs :

This howto needs one of these tools, according to the installed HTTP server :

Parameters

Provide the domain name where will be available the software :

DOMAIN="files.example-domain.com"

Provide the MySQL server host :

MYSQL_HOST="localhost"

If the MySQL server is not local, the mysql-tools script will try to connect with MySQL client, or in case of connection failure, through SSH.

Installation

Compute the installation path :

INSTALL_PATH="/opt/openupload/${DOMAIN}"

Make sure that the parent folder exists :

PARENT_PATH="$(command dirname "${INSTALL_PATH}")"
if [ ! -e "${PARENT_PATH}" ]; then
command mkdir --parent "${PARENT_PATH}"
fi

Environment preparation

Install the needed software :

command apt-get install php5-mysql php5-gd

Adjust PHP configuration to the application needs :

command php-tools --for="open-upload" --set "upload_max_filesize" "750M"
command php-tools --for="open-upload" --set "post_max_size" "750M"

Reload PHP configuration :

test -x /etc/init.d/php5-fpm && /etc/init.d/php5-fpm force-reload
test -x /etc/init.d/apache2 && /etc/init.d/apache2 force-reload
test -x /etc/init.d/lighttpd && /etc/init.d/lighttpd force-reload
test -x /etc/init.d/nginx && /etc/init.d/nginx force-reload

Application installation

Fetch the latest sources using the sf-downloader script :

command mkdir --parent '/opt/bin'
command wget 'https://raw.github.com/biapy/howto.biapy.com/master/various/sf-downloader' \
--quiet --no-check-certificate --output-document='/opt/bin/sf-downloader'
command chmod +x '/opt/bin/sf-downloader'
SOURCE="$(/opt/bin/sf-downloader --tgz openupload openupload-VERSION.tar.gz)"

Move the source folder to the install path :

command mv "${SOURCE}" "${INSTALL_PATH}"

Fix the ".htaccess" file in case of Apache 2 not using mod_php5 :

command echo "<IfModule mod_php5.c>
$(command cat "${INSTALL_PATH}/www/.htaccess")
</IfModule>" > "${INSTALL_PATH}/www/.htaccess"

Conformity with LSB

Move data and cache folders to fit Linux Standard Base :

command chown -R root:root "${INSTALL_PATH}"
command mkdir --parent "/var/lib/openupload"
command mv "${INSTALL_PATH}/data" "/var/lib/openupload/${DOMAIN}"
command ln -s "/var/lib/openupload/${DOMAIN}" "${INSTALL_PATH}/data"
command chown -R www-data:www-data "/var/lib/openupload/${DOMAIN}"
command mkdir --parent "/var/cache/openupload"
command mv "${INSTALL_PATH}/templates_c" "/var/cache/openupload/${DOMAIN}"
command ln -s "/var/cache/openupload/${DOMAIN}" "${INSTALL_PATH}/templates_c"
command chown -R www-data:www-data "/var/cache/openupload/${DOMAIN}"
command chown www-data:www-data "${INSTALL_PATH}/www"

Database creation

Create the database with mysql-tools :

MYSQL_PARAMS="$(command mysql-tools --server="${MYSQL_HOST}" --with-ssh \
--auto-hosts --db-prefix="open-upload" --create "${DOMAIN}")"

Get the created database connection parameters and write them down :

echo "${MYSQL_PARAMS}"

Virtual host setup

Setup the HTTP server for the application :

if [ -x "/usr/bin/a2tools" ]; then
  command a2tools --overrides="Options" "${DOMAIN}" "${INSTALL_PATH}/www"
fi
if [ -x "/usr/bin/lighty-tools" ]; then
  command lighty-tools add-vhost "${DOMAIN}" "${INSTALL_PATH}/www"
fi

The software should now be available on the domain name.

Initialisation

Complete the installation by browsing the URL provided by :

command echo "http://${DOMAIN}/"

Setup the application.

Locking configuration

Once the installation complete, remove write permissions from configuration file :

command chown -R root:root "${INSTALL_PATH}/www"

Backup

Backup the installation with Backup Manager (see Install and setup Backup Manager on Debian) :

command backup-manager-tools add "${INSTALL_PATH}"
command backup-manager-tools add "/var/lib/openupload/${DOMAIN}"

Don't forget to backup the database (see Install and setup MySQL on Debian)

Software upgrade

Provide the application domain name :

DOMAIN="files.example-domain.com"

Compute the installation path :

INSTALL_PATH="/opt/openupload/${DOMAIN}"

Fetch the latest sources using the sf-downloader script :

command mkdir --parent '/opt/bin'
command wget 'https://raw.github.com/biapy/howto.biapy.com/master/various/sf-downloader' \
--quiet --no-check-certificate --output-document='/opt/bin/sf-downloader'
command chmod +x '/opt/bin/sf-downloader'
SOURCE="$(/opt/bin/sf-downloader --tgz openupload openupload-VERSION.tar.gz)"

Copy the data from the outdated install :

command rm -r "${SOURCE}/data"
command cp -a "${INSTALL_PATH}/data" "${SOURCE}"
command rm -r "${SOURCE}/templates_c"
command cp -a "${INSTALL_PATH}/templates_c" "${SOURCE}"
command cp -a "${INSTALL_PATH}/www/config.inc.php" "${SOURCE}/www"

Fix the ".htaccess" file in case of Apache 2 not using mod_php5 :

command echo "<IfModule mod_php5.c>
$(command cat "${SOURCE}/www/.htaccess")
</IfModule>" > "${SOURCE}/www/.htaccess"

Backup the outdated install :

if [ -e "${INSTALL_PATH}.old" ]; then
command rm -r "${INSTALL_PATH}.old"
fi
command mv "${INSTALL_PATH}" "${INSTALL_PATH}.old"

Install the latest version :

command mv "${SOURCE}" "${INSTALL_PATH}"

Check that everything work and delete backup data :

command rm -r "${INSTALL_PATH}.old"

Thanks