Zum Inhalt

Install Seafile 5.1 on Debian 7.10 with Apache 2.2 and Plesk 10.5

Installing Seafile on a system that is maintained by Plesk can be a little bit tricky, especially if you are using Debian 7 with Apache 2.2. Therefore I wrote a small tutorial which will explain how to install seafile on a new created subdomain.


Debian 7.10
Plesk 10.5
Domain set up with valid SSL Certificate

Create subdomain in Plesk

Create a subdomain in Plesk where Seafile will be installed

  • Login to Plesk
  • Select Websites & Domains and choose Add Subdomain
  • Enter the subdomain URL you want your seafile to be reachable, in this example we will use as an example seafile.mydomain.com
  • Go to File Manager in Plesk and choose to delete the complete content of the folder of the subdomain

Entering the URL seafile.mydomain.com in your browser will now show the default Plesk Page.

Downloading Seafile on your server

  • Open your browser and go to seafile.com and select the Download section
  • Depending on your system copy the download link of the x86 oder x64 server version of Seafile for Linux to download:
  • Tip: If you are unsure if you are running a 32 or 64-bit system, type uname -m in your SSH console. x86_64 or amd64 will show up when you are using a 64-bit system.
  • Login to your sever via SSH and navigate to your subdomain folder
    cd var/www/vhosts/mydomain.com/seafile.mydomain.com
  • Download Seafile via wget
    wget https://bintray.com/artifact/download/seafile-org/seafile/seafile-server_5.1.3_x86-64.tar.gz
  • Extract the archive
    tar -xzf seafile-server_5.1.3_x86-64.tar.gz

Setting up MySQL database

We will now create a Seafile MySQL user and set up the database structure. Due to some Plesk configurations these steps cannot be performed by Seafile but need to be done manually.

  • Login as MySQL admin user in your SSH console
    mysql -uadmin -p cat /etc/psa/.psa.shadow
  • Create the databases, create a seafile user and grant access to it
    create database `ccnet-db` character set = 'utf8';
    create database `seafile-db` character set = 'utf8';
    create database `seahub-db` character set = 'utf8';

    create user 'seafile'@'' identified by 'seafile';
    GRANT ALL PRIVILEGES ON `ccnet-db`.* to `seafile`@;
    GRANT ALL PRIVILEGES ON `seafile-db`.* to `seafile`@;
    GRANT ALL PRIVILEGES ON `seahub-db`.* to `seafile`@;
  • Quit the MySQL prompt

Installing Seafile

Now we are ready to perform the Seafile installation.

  • Get your Debian up-to-date and install required packages
    apt-get update
    apt-get upgrade
    apt-get install python2.7 libpython2.7 python-setuptools python-imaging python-ldap python-mysqldb python-memcache python-urllib3 libapache2-mod-fastcgi
  • Confirm to install these required packages
  • Start the seafile setup
    cd seafile-server-5.1.3
  • Follow the steps in the installation script and enter your information. For the MySQL database connection information the default vaulues can be chosen but be sure to enter the correct database names when you are being asked for them.
    Enter the existing database name for ccnet:
    [ ccnet database ] ccnet-db
    verifying user "seafile" access to database ccnet-db ...  done

    Enter the existing database name for seafile:
    [ seafile database ] seafile-db
    verifying user "seafile" access to database seafile-db ...  done

    Enter the existing database name for seahub:
    [ seahub database ] seahub-db
    verifying user "seafile" access to database seahub-db ...  done
  • Start Seafile and Seahub for the first time and create the admin account for Seafile
    ./seafile.sh start
    ./seahub.sh start
  • Seafile should now already be reachable via http://seafile.mydomain.com:8000
  • Now we need to change the config for seafile to support https connections
    vi /var/www/vhosts/mydomain.com/seafile.mydomain.com/conf/ccnet.conf
    Change SERVICE_URL = http://seafile.mydomain.com to SERVICE_URL = https://seafile.mydomain.com
  • Edit the Seahub Config
    vi /var/www/vhosts/mydomain.com/seafile.mydomain.com/conf/seahub_settings.py
    Add the following line:
    FILE_SERVER_ROOT = ‚https://seafile.mydomain.com/seafhttp‘

Configurating Apache for Seafile

  • Check that all required mods for Apache are enabled
    a2enmod rewrite
    a2enmod fastcgi
    a2enmod proxy_http
  • Edit the Apache2 config
    vi /etc/apache2/apache2.conf
  • Add the FastCGI option for Seafile at the end of the config file
    FastCGIExternalServer /var/www/vhosts/mydomain.com/seafile.mydomain.com/seahub.fcgi -host
  • Restart Apache
    service apache2 restart
  • Go back to Plesk and edit the Apache & nginx Settings for your subdomain
  • First we will add a https redirect so that seafile will only be reachable via https. Add the following lines to Additional directives for http:
    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
  • For „Additional directives for https“ we need to add:
    <Directory "/var/www/vhosts/mydomain.com/seafile.mydomain.com">
    Options FollowSymlinks
    AllowOverride None
    Order allow,deny
    Allow from all
    </Directory>DocumentRoot /var/www/vhosts/mydomain.com/seafile.mydomain.com
    Alias /media  /var/www/vhosts/mydomain.com/seafile.mydomain.com/seafile-server-latest/seahub/mediaRewriteEngine On
    # seafile httpserver
    ProxyPass /seafhttp
    ProxyPassReverse /seafhttp
    RewriteRule ^/seafhttp - [QSA,L]>
    # seahub
    RewriteRule ^/(media.*)$ /$1 [QSA,L,PT]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ /seahub.fcgi/$1 [QSA,L,E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

Restarting Seafile in FastCGI mode

Now we stop Seafile and restart it in FastCGI Mode:
cd /var/www/vhosts/mydomain.com/seafile.mydomain.com/seafile-server-latest
./seafile.sh stop
./seahub.sh stop
./seafile.sh start
./seahub.sh start-fastcgi

Now Seafile is reachable via browser at https://seafile.mydomain.com

Automatically start Seafile on Server startup (optional)

If you want Seafile to start automatically when the servers starts you additionally need to perform the following steps:

#vi /etc/init.d/seafile-server

Add the following content

# Provides:          seafile-server
# Required-Start:    $local_fs $remote_fs $network mysql
# Required-Stop:     $local_fs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Starts Seafile Server
# Description:       starts Seafile Server

# Change the value of "user" to linux user name who runs seafile

# Change the value of "seafile_dir" to your path of seafile installation
# usually the home directory of $user

# Change the value of fastcgi to true if fastcgi is to be used
# Set the port of fastcgi, default is 8000. Change it if you need different.

# Write a polite log message with date and time
echo -e "\n \n About to perform $1 for seafile at `date -Iseconds` \n " >> ${seafile_init_log}
echo -e "\n \n About to perform $1 for seahub at `date -Iseconds` \n " >> ${seahub_init_log}

case "$1" in
sudo -u ${user} ${script_path}/seafile.sh ${1} >> ${seafile_init_log}
if [ $fastcgi = true ];
sudo -u ${user} ${script_path}/seahub.sh ${1}-fastcgi ${fastcgi_port} >> ${seahub_init_log}
sudo -u ${user} ${script_path}/seahub.sh ${1} >> ${seahub_init_log}
sudo -u ${user} ${script_path}/seafile.sh ${1} >> ${seafile_init_log}
if [ $fastcgi = true ];
sudo -u ${user} ${script_path}/seahub.sh ${1}-fastcgi ${fastcgi_port} >> ${seahub_init_log}
sudo -u ${user} ${script_path}/seahub.sh ${1} >> ${seahub_init_log}
sudo -u ${user} ${script_path}/seahub.sh ${1} >> ${seahub_init_log}
sudo -u ${user} ${script_path}/seafile.sh ${1} >> ${seafile_init_log}
echo "Usage: /etc/init.d/seafile-server {start|stop|restart}"
exit 1

After that perform the following commands in your SSH console:
chmod +x /etc/init.d/seafile-server
update-rc.d seafile-server defaults

Published inEnglishHow-ToSoftware

Schreibe den ersten Kommentar

Schreibe einen Kommentar