Seafile: make your personal storage cloud easily

From Deimos.fr / Bloc Notes Informatique
Jump to: navigation, search
Seafile

Software version Seafile 3.0
Operating System Debian 7
Website Seafile Website
Last Update 22/06/2014
Others

1 Introduction

Seafile[1] is a next-generation open source cloud storage system, with advanced support for file syncing, privacy protection and teamwork.

Collections of files are called libraries, and each library can be synced separately. A library can be encrypted with a user chosen password. This password is not stored on the server, so even the server admin can't view your file contents.

Seafile lets you create groups with file syncing, wiki, and discussion enabling easy collaboration around documents within a team.

For this documentation, you need to have:

  1. A web server (here Nginx)
  2. A MariaDB/MySQL server
  3. Python installed

2 Installation

The installation of Seafile is not complicated but a little bit long. First of all, you need o grab the latest seafile version:

Command
mkdir -p /usr/share/nginx/www/seafile
cd /usr/share/nginx/www/seafile
wget https://bitbucket.org/haiwen/seafile/downloads/seafile-server_3.0.0_x86-64.tar.gz
tar -xzf seafile-server_3.0.0_x86-64.tar.gz
chown -Rf www-data. seafile-server-3.0.0

Then we need to install dependencies:

Command aptitude
aptitude install python-simplejson python-setuptools python-mysqldb python-imaging

3 Configuration

3.1 MariaDB

The first thing to do is to configure MariaDB accounts and create databases (adapt those lines with your needs):

Command mysql
CREATE DATABASE `seafile\_ccnet`;
CREATE DATABASE `seafile\_db`;
CREATE DATABASE `seafile\_hub`;
CREATE USER 'seafile_user'@'127.0.0.1' identified by 'password';
GRANT ALL PRIVILEGES ON `seafile\_ccnet` . * TO 'seafile_user'@'127.0.0.1';
GRANT ALL PRIVILEGES ON `seafile\_db` . * TO 'seafile_user'@'127.0.0.1';
GRANT ALL PRIVILEGES ON `seafile\_hub` . * TO 'seafile_user'@'127.0.0.1';
FLUSH PRIVILEGES;

Then you have to launch the installer:

Command
> ./setup-seafile-mysql.sh
[...]
-------------------------------------------------------
Please choose a way to initialize seafile databases:
-------------------------------------------------------
 
[1] Create new ccnet/seafile/seahub databases
[2] Use existing ccnet/seafile/seahub databases

Choose to use existing databases and credentials when it is asked to you. The 1 choice can be used but as I encountered issues, that's why I did it manually.

3.2 Ccnet

Regarding the ccnet configuration, there is nothing to do especially instead of if you want SSL instead. If you want https, modify the SERVICE_URL like this:

Configuration File

ccnet/ccnet.conf

[General]
SERVICE_URL = https://seafile.deimos.fr
...

3.3 Seahub

For SSL as well, update this file by adding on top of the file this kind of line:

Configuration File seahub_settings.py
HTTP_SERVER_ROOT = 'https://seafile.deimos.fr/seafhttp'

3.4 Webdav

To implement webdav for clients that can't use Seafile client, add this configuration:

Configuration File /usr/share/nginx/www/seafile/conf/seafdav.conf
[WEBDAV]
enabled = true
port = 8080
fastcgi = true
share_name = /seafdav

3.5 Nginx

Now to finish, here is an example of Nginx configuration for SSL purpose:


Configuration File /etc/nginx/sites-available/seafile.deimos.fr
server {
    include listen_port.conf;
    server_name seafile.deimos.fr;
    # Force redirect http to https
    rewrite ^ https://$http_host$request_uri? permanent;
}
 
server {
    include ssl/deimos.fr_ssl.conf;
 
    include pagespeed.conf;
    server_name seafile.deimos.fr;
 
    root /usr/share/nginx/www/deimos.fr/seafile;
 
    access_log /var/log/nginx/seafile.deimos.fr_access.log;
    error_log /var/log/nginx/seafile.deimos.fr_error.log;
 
    # Max upload size
    client_max_body_size 1G;
 
    location / {
        fastcgi_pass    127.0.0.1:8090;
        fastcgi_param   SCRIPT_FILENAME     $document_root$fastcgi_script_name;
        fastcgi_param   PATH_INFO           $fastcgi_script_name;
        fastcgi_param   SERVER_PROTOCOL     $server_protocol;
        fastcgi_param   QUERY_STRING        $query_string;
        fastcgi_param   REQUEST_METHOD      $request_method;
        fastcgi_param   CONTENT_TYPE        $content_type;
        fastcgi_param   CONTENT_LENGTH      $content_length;
        fastcgi_param   SERVER_ADDR         $server_addr;
        fastcgi_param   SERVER_PORT         $server_port;
        fastcgi_param   SERVER_NAME         $server_name;
        fastcgi_param   REMOTE_ADDR         $remote_addr;
        fastcgi_param   HTTPS               on;
        fastcgi_param   HTTP_SCHEME         https;
    }
 
    # Webdav
    location /seafdav {
        fastcgi_pass    127.0.0.1:8080;
        fastcgi_param   SCRIPT_FILENAME     $document_root$fastcgi_script_name;
        fastcgi_param   PATH_INFO           $fastcgi_script_name;
 
        fastcgi_param   SERVER_PROTOCOL     $server_protocol;
        fastcgi_param   QUERY_STRING        $query_string;
        fastcgi_param   REQUEST_METHOD      $request_method;
        fastcgi_param   CONTENT_TYPE        $content_type;
        fastcgi_param   CONTENT_LENGTH      $content_length;
        fastcgi_param   SERVER_ADDR         $server_addr;
        fastcgi_param   SERVER_PORT         $server_port;
        fastcgi_param   SERVER_NAME         $server_name;
 
        fastcgi_param   HTTPS               on;
    }
 
    location /seafhttp {
        rewrite ^/seafhttp(.*)$ $1 break;
        proxy_pass http://127.0.0.1:8082;
        client_max_body_size 0;
    }
 
    location /media {
        root /var/www/deimos.fr/seafile/seafile-server-latest/seahub;
    }
}

3.6 Init script

Regarding the init script, add it and adapt the highlighted lines:

Configuration File /etc/init.d/seafile-server
  1. #!/bin/sh
  2.  
  3. ### BEGIN INIT INFO
  4. # Provides:          seafile-server
  5. # Required-Start:    $local_fs $remote_fs $network
  6. # Required-Stop:     $local_fs
  7. # Default-Start:     2 3 4 5
  8. # Default-Stop:      0 1 6
  9. # Short-Description: Starts Seafile Server
  10. # Description:       starts Seafile Server
  11. ### END INIT INFO
  12.  
  13. # Change the value of "user" to your linux user name
  14. user=www-data
  15.  
  16. # Change the value of "script_path" to your path of seafile installation
  17. seafile_dir=/usr/share/nginx/www/deimos.fr/seafile
  18. script_path=${seafile_dir}/seafile-server-latest
  19. seafile_init_log=${seafile_dir}/logs/seafile.init.log
  20. seahub_init_log=${seafile_dir}/logs/seahub.init.log
  21.  
  22. # Change the value of fastcgi to true if fastcgi is to be used
  23. fastcgi=true
  24. # Set the port of fastcgi, default is 8000. Change it if you need different.
  25. fastcgi_port=8090
  26.  
  27. case "$1" in
  28.         start)
  29.                 sudo -u ${user} ${script_path}/seafile.sh start >> ${seafile_init_log}
  30.                 if [  $fastcgi = true ];
  31.                 then
  32.                         sudo -u ${user} ${script_path}/seahub.sh start-fastcgi ${fastcgi_port} >> ${seahub_init_log}
  33.                 else
  34.                         sudo -u ${user} ${script_path}/seahub.sh start >> ${seahub_init_log}
  35.                 fi
  36.         ;;
  37.         restart)
  38.                 sudo -u ${user} ${script_path}/seafile.sh restart >> ${seafile_init_log}
  39.                 if [  $fastcgi = true ];
  40.                 then
  41.                         sudo -u ${user} ${script_path}/seahub.sh restart-fastcgi ${fastcgi_port} >> ${seahub_init_log}
  42.                 else
  43.                         sudo -u ${user} ${script_path}/seahub.sh restart >> ${seahub_init_log}
  44.                 fi
  45.         ;;
  46.         stop)
  47.                 sudo -u ${user} ${script_path}/seafile.sh $1 >> ${seafile_init_log}
  48.                 sudo -u ${user} ${script_path}/seahub.sh $1 >> ${seahub_init_log}
  49.         ;;
  50.         *)
  51.                 echo "Usage: /etc/init.d/seafile {start|stop|restart}"
  52.                 exit 1
  53.         ;;
  54. esac

I've changed the default port as mine was already used.

Then activate it on boot:

Command
chmod 755 /etc/init.d/seafile-server
update-rc.d seafile-server defaults

You can now reload your Nginx configuration and start Seafile:

Command
service nginx reload
service seafile-server start

You should have access to Seafile now :-)

4 References

  1. ^ http://seafile.com