Installation Seafile (Replikationsdienst)

Hallo Freunde der Sonne,

heute geht es um die Aufarbeitung eines netten Cloud-Dienstes, der im Notfall sogar lokal installiert werden kann. Aufgabe von Seafile ist es eine „Bibliothek“ zu hosten, die dann via Seafile-Client auf jedem Gerät synchron gehalten wird. Also ein einfacher Dateireplikationsdienst.

Installation Seafile (Replikationsdienst)

Quelle für Installation: http://manual.seafile.com/deploy/using_mysql.html
Quelle für Downloads: http://seafile.com/en/download/
(die Sprache wird nach der Installation ausgewählt)

Quelle für Lizenzierung privater Server: http://seafile.com/en/product/private_server/
Quelle für Lizenzierung Cloud: http://seafile.com/en/product/cloud_service/

Quelle für Apache-CGI-rProxy: http://pkgs.repoforge.org/mod_fastcgi/
Quelle alternativ: https://jenswatch.de/wp-content/uploads/2015/07/mod_fastcgi-2.4.6-1.el6_.rf_.x86_64.rpm_.zip

Lizenzierung: GPLv2 (basiert auf Komponenten von GitHub)

  • Community-Edition (kein Cluster, weniger Features) = kostenfrei
  • Professional-Edition = Benutzer-Lizenz (gestaffelt nach Stückzahl)

Vorbereitung für die Installation

  1. Installation im Beispiel auf CentOS 6.6 (minimal)
  2. Verwendung von MySQL-Server
  3. Absicherung der Kommunikation via Apache CGI-rProxy mit Zertifikaten (SSL/TLS)
  4. Einbindugn in den Autostart

Alle Punkte sind in der Online-Doku aufgeschlüsselt, daher ist dieser Leitfaden nur für die Express-Bereitstellung formuliert.

Installation Seafile & MySQL

Bitte zuerst das EPEL-Repo installieren und ein System-Update durchführen:

cd /root
yum install wget ntsysv nano openssl
wget https://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -i epel-release-6-8.noarch.rpm
yum update

Nun den Web+Datenbankdienst intallieren:

yum install httpd mod_ssl php php-mysql mysql-server

Bitte vergeben Sie ein Kennwort für den MySQL-root:

service httpd start
service mysqld start
mysqladmin -u root password <PASSWORD>

Führe folgendes Skript auf dem MySQL-Server aus:

create database `ccnet-db` character set = 'utf8';
create database `seafile-db` character set = 'utf8';
create database `seahub-db` character set = 'utf8';

create user 'seafile'@'localhost' identified by 'seafile';

GRANT ALL PRIVILEGES ON `ccnet-db`.* to `seafile`@localhost;
GRANT ALL PRIVILEGES ON `seafile-db`.* to `seafile`@localhost;
GRANT ALL PRIVILEGES ON `seahub-db`.* to `seafile`@localhost;

flush privileges;

Nimm die Autostart-Konfiguration vor:

ntsysv

Deaktiviere SELINUX: /etc/selinux/config

SELINUX=disabled
SELINUXTYPE=targeted

Nun bitte den Apache-CGI-rProxy herunterladen und installieren (WICHTIG: mod_fastgci):

wget http://pkgs.repoforge.org/mod_fastcgi/mod_fastcgi-2.4.6-1.el6.rf.x86_64.rpm
rpm -i mod_fastcgi-2.4.6-1.el6.rf.x86_64.rpm

Jetzt lade den Seafile-Server herunter:

mkdir /opt/seafile
mkdir /opt/seafile/installed
cd /opt/seafile/installed
wget https://bintray.com/artifact/download/seafile-org/seafile/seafile-server_4.2.3_x86-64.tar.gz
cd ..
tar xvzf /root/seafile-server_4.2.3_x86-64.tar.gz

Installiere die Python-Abhängigkeiten:

yum install python python-setuptools python-imaging MySQL-python python-flup

Starte den Installations-Assistenten:

cd seafile-server-*
./setup-seafile-mysql.sh
ulimit -n 30000

Passe das CCNET-Konfigurations-File an: /opt/seafile/ccnet/ccnet.conf

[General]
SERVICE_URL = https://subdomain.domain.tld

Passe den Sync-Pfad an: /opt/seafile/seahub_settings.py

FILE_SERVER_ROOT = 'https://subdomain.domain.tld/seafhttp'

Füge folgende Zeile im Apache hinzu: /etc/httpd/conf/httpd.conf

AddHandler cgi-script .cgi .fcgi
NameVirtualHost *:443
FastCGIExternalServer /var/www/html/seahub.fcgi -host 127.0.0.1:8000

Erstelle diese Datei für den virtuellen Zugriff:

touch /var/www/html/seahub.fcgi

Erstelle folgende virtuelle Website: /etc/httpd/conf.d/seafile.conf

<VirtualHost *:443>
    ServerName subdomain.domain.tld

#    LogLevel warn
    SSLEngine on
#    SSLProtocol all
    #SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM:+LOW


    SSLCertificateFile /etc/pki/tls/certs/subdomain.domain.tld.crt
    SSLCertificateKeyFile /etc/pki/tls/private/subdomain.domain.tld.key

#    <Files ~ "\.(cgi|shtml|phtml|php?)$">
#           SSLOptions +StdEnvVars
 #   </Files>


    # Use "DocumentRoot /var/www/html" for Centos/Fedora
    # Use "DocumentRoot /var/www" for Ubuntu/Debian
    DocumentRoot /var/www/html
    Alias /media  /opt/seafile/seafile-server-latest/seahub/media

    RewriteEngine On

    # For apache2.2, you may need to change to
      <Location /media>
        Order allow,deny
        Allow from all
      </Location>
    #<Location /media>
    #    Require all granted
    #</Location>

    #
    # seafile fileserver
    #
    ProxyPass /seafhttp http://127.0.0.1:8082
    ProxyPassReverse /seafhttp http://127.0.0.1:8082
    RewriteRule ^/seafhttp - [QSA,L]
    # For apache2.2, you may need to add
      <Location /seafhttp>
        Order allow,deny
        Allow from all
     </Location>

    #
    # seahub
    #
    RewriteRule ^/(media.*)$ /$1 [QSA,L,PT]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ /seahub.fcgi$1 [QSA,L,E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

#    SetEnvIf User-Agent ".*MSIE.*" \
#            nokeepalive ssl-unclean-shutdown \
#    downgrade-1.0 force-response-1.0
#
#    CustomLog logs/ssl_request_log \
#            "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
</VirtualHost>

Autostartkonfiguration

Erstelle folgende Datei für sysconfig: /etc/sysconfig/seafile

# Change the value of "user" to your linux user name
user=root

# Change the value of "script_path" to your path of seafile installation
# usually the home directory of $user
seafile_dir=/opt/seafile
script_path=${seafile_dir}/seafile-server-latest
seafile_init_log=${seafile_dir}/logs/seafile.init.log
seahub_init_log=${seafile_dir}/logs/seahub.init.log

# Change the value of fastcgi to true if fastcgi is to be used
fastcgi=true

# Set the port of fastcgi, default is 8000. Change it if you need different.
fastcgi_port=8000

Erstelle eine Dienststeuerung für seafile: /etc/init.d/seafile

#!/bin/bash
#
# seafile

#
# chkconfig: - 68 32
# description: seafile

# Source function library.
. /etc/init.d/functions

# Source networking configuration.
. /etc/sysconfig/network

if [ -f /etc/sysconfig/seafile ];then
        . /etc/sysconfig/seafile
        else
            echo "Config file /etc/sysconfig/seafile not found! Bye."
            exit 200
        fi

RETVAL=0

start() {
        # Start daemons.
        echo -n $"Starting seafile: "
        ulimit -n 30000
        su - ${user} -c"${script_path}/seafile.sh start >> ${seafile_init_log} 2>&1"
        RETVAL=$?
        echo
        [ $RETVAL -eq 0 ] && touch /var/lock/subsys/seafile
        return $RETVAL
}

stop() {
        echo -n $"Shutting down seafile: "
        su - ${user} -c"${script_path}/seafile.sh stop >> ${seafile_init_log} 2>&1"
        RETVAL=$?
        echo
        [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/seafile
        return $RETVAL
}

#
# 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}

# See how we were called.
case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  restart|reload)
        stop
        start
        RETVAL=$?
        ;;
  *)
        echo $"Usage: $0 {start|stop|restart}"
        RETVAL=3
esac

exit $RETVAL

Erstelle eine Dienststeuerung für seahub: /etc/init.d/seahub

#!/bin/bash
#
# seahub

#
# chkconfig: - 69 31
# description: seahub

# Source function library.
. /etc/init.d/functions

# Source networking configuration.
. /etc/sysconfig/network

if [ -f /etc/sysconfig/seafile ];then
        . /etc/sysconfig/seafile
        else
            echo "Config file /etc/sysconfig/seafile not found! Bye."
            exit 200
        fi

RETVAL=0

start() {
        # Start daemons.
        echo -n $"Starting seahub: "
        ulimit -n 30000
        if [  $fastcgi = true ];
                then
                su - ${user} -c"${script_path}/seahub.sh start-fastcgi ${fastcgi_port} >> ${seahub_init_log} 2>&1"
                else
                su - ${user} -c"${script_path}/seahub.sh start >> ${seahub_init_log} 2>&1"
                fi
        RETVAL=$?
        echo
        [ $RETVAL -eq 0 ] && touch /var/lock/subsys/seahub
        return $RETVAL
}

stop() {
        echo -n $"Shutting down seahub: "
        su - ${user} -c"${script_path}/seahub.sh stop >> ${seahub_init_log} 2>&1"
        RETVAL=$?
        echo
        [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/seahub
        return $RETVAL
}

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

# See how we were called.

case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  restart|reload)
        stop
        start
        RETVAL=$?
        ;;
  *)
        echo $"Usage: $0 {start|stop|restart}"
        RETVAL=3
esac

exit $RETVAL

Passe die Berechtigungen an und übernehme die Seafile-Dienste in die Startup-Konfiguration:

chmod 550 /etc/init.d/seafile
chmod 550 /etc/init.d/seahub
chkconfig --add seafile
chkconfig --add seahub
chkconfig seahub on
chkconfig seafile on
service seafile start
service seahub start

Gehe sicher, dass in der Firewall der SSL-Port freigegeben ist: /etc/sysconfig/iptables

-A INPUT -p tcp -m state --state NEW -m tcp --dport 443 -j ACCEPT

Nun sollte Seafile komplett über ein SSL-Zertifikat von extern erreichbar seien.