User Tools

Site Tools


fileservices:seafile

Seafile 2.x on Ubuntu 12.04

Download and Install

  1. install deps
    apt-get install python2.7 python-setuptools python-simplejson\
     python-imaging python-mysqldb mysql-server
  2. extract and install
    mkdir /vol1/seafile/
    cd /vol1/seafile/
    wget http://seafile.googlecode.com/files/seafile-server_2.0.1_x86-64.tar.gz
    tar xvzf http://seafile.googlecode.com/files/seafile-server_2.0.1_x86-64.tar.gz
    rm seafile-server_2.0.1_x86-64.tar.gz
    cd /vol1/seafile/seafile-server-2.0.1
    ./setup-seafile-mysql.sh
  3. Setup Smtp Server
    /vol1/seafile/seahub_settings.py
    ...
    EMAIL_USE_TLS = False
    EMAIL_HOST = 'smtp.mail.org'        # smpt server
    EMAIL_HOST_USER = 'seafile@mail.org'    # username and domain
    #EMAIL_HOST_PASSWORD = ''    # password
    EMAIL_PORT = '25'
    DEFAULT_FROM_EMAIL = EMAIL_HOST_USER
    SERVER_EMAIL = EMAIL_HOST_USER
    ...

Enable Seafile Automatic Startup

  1. create /etc/init.d/seafile
    /etc/init.d/seafile
    #!/bin/sh
    ### BEGIN INIT INFO
    # Provides:             seafile-server
    # Required-Start:       $all
    # Required-Stop:        $all
    # Should-Start:         $local_fs mysql
    # Should-Stop:          $local_fs
    # Default-Start:        2 3 4 5
    # Default-Stop:         0 1 6
    ### END INIT INFO
     
    # Change the value of "user" to your linux user name
    user=root
     
    # Change the value of "script_path" to your path of seafile installation
    seafile_dir=/vol1/seafile
    script_path=${seafile_dir}/seafile-server-2.0.1
    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=false
     
    case "$1" in
            start)
                    service mysql start
                    sudo -u ${user} ${script_path}/seafile.sh start > ${seafile_init_log}
                    if [  $fastcgi = true ];
                    then
                            sudo -u ${user} ${script_path}/seahub.sh start-fastcgi > ${seahub_init_log}
                    else
                            sudo -u ${user} ${script_path}/seahub.sh start > ${seahub_init_log}
                    fi
            ;;
            restart)
                    sudo -u ${user} ${script_path}/seafile.sh restart > ${seafile_init_log}
                    if [  $fastcgi = true ];
                    then
                            sudo -u ${user} ${script_path}/seahub.sh restart-fastcgi > ${seahub_init_log}
                    else
                            sudo -u ${user} ${script_path}/seahub.sh restart > ${seahub_init_log}
                    fi
            ;;
            stop)
                    sudo -u ${user} ${script_path}/seafile.sh $1 > ${seafile_init_log}
                    sudo -u ${user} ${script_path}/seahub.sh $1 > ${seahub_init_log}
            ;;
            *)
                    echo "Usage: /etc/init.d/seafile {start|stop|restart}"
                    exit 1
            ;;
    esac
  2. Turn on automatic startup
    # make the script executable
    sudo chmod +x /etc/init.d/seafile
    # update system rc.d config to enable seafile-server
    sudo update-rc.d seafile defaults
    # restart once to make sure everything is running
    echo "/etc/init.d/seafile restart" >> /etc/rc.local

Enable SSL through Apache2 on port 443

  1. Install Apache and enable mods
    apt-get install python-flup apache2 libapache2-mod-fastcgi
    a2enmod proxy_http
    a2enmod rewrite
    a2enmod ssl
    a2ensite default-ssl
  2. Enable fastcgi on seafile
    /etc/init.d/seafile
    ...
    # Change the value of fastcgi to true if fastcgi is to be used
    fastcgi=true
    ...
  3. Create ssl certs
    mkdir /vol1/seafile/ssl
    cd /vol1/seafile/ssl
    openssl genrsa -out privkey.pem 2048
    openssl req -new -x509 -key privkey.pem -out cacert.pem -days 9999
  4. Update apache ssl virtual host
    /etc/apache2/sites-enabled/default-ssl
    ...
    SSLCertificateFile    /vol1/seafile/ssl/cacert.pem
    SSLCertificateKeyFile /vol1/seafile/ssl/privkey.pem
     
    FastCGIExternalServer /vol1/seafile/seafile-server-2.0.1/seahub/seahub.fcgi -host 127.0.0.1:8000
     
    DocumentRoot /vol1/seafile/seafile-server-2.0.1/seahub
    Alias /media /vol1/seafile/seafile-server-2.0.1/seahub/media
    RewriteEngine On
    RewriteRule ^/(media.*)$ /$1 [QSA,L,PT]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ /seahub.fcgi/$1 [QSA,L,E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
    ...
  5. Update SERVICE_URL in ccnet.conf
    /vol1/seafile/ccnet/ccnet.conf
    ...
    SERVICE_URL = https://<SERVER FQDN>
    ...
  6. Disable port 80 on apache
    /etc/apache2/ports.conf
    ...
    #NameVirtualHost *:80
    #Listen 80
    ...

Exclude Files

Sometimes you don't want to sync some files or folders inside a library. To achieve this, create a seafile-ignore.txt file in the root folder of a library. This special file specifies the files and folders that Seafile should not sync. Each line in a ignore.txt file specifies a pattern. The following pattern format are supported.

  1. A blank line matches no files.
  2. A line starting with # serves as a comment.
  3. Seafile supports wildcards in the pattern. For example, “foo/*” matches “foo/1” and “foo/hello”. “foo/?” matches “foo/1” but not “foo/hello”. Note that the wildcard character * recursively matches all the paths under a folder. For instance, “foo/*.html” matches “foo/a.html” and “foo/templates/b.html”.
  4. If the pattern ends with a slash, it would only match a folder. In other words, foo/ will match a folder “foo” and paths underneath it, but will not match a regular file or a symbolic link “foo”.
  5. If a pattern doesn't end with a slash or a wildcard, it would not match a folder. For example, “foo” can only match regular file “foo” or a symbolic link; while “foo/” and “foo*” match a folder and paths under it.
seafile-ignore.txt
# a regular file
test-file
 
# a dir
test-dir/
 
# wildcard *
test-star1/*
test-star2/*.html
 
# wildcard ?
test-qu1/?.html
test-qu2/?/
fileservices/seafile.txt · Last modified: 2013/10/25 14:52 by tschulz