I discovered Seafile in search for an alternative to OwnCloud which could not manage to sync my large collection of files (100Gb and 80000 files). It took many hours just to discover which files to sync. Luckily I found Seafile, which is one of the best open-source file syncing solutions out there. It’s written in Python/Django and C. It’s fast and does exactly what it needs to.
This is a quick tutorial how to set up an entire cloud file server appliance on Debian Wheezy 7 64bit.
Install Seafile
Choose your preferred location to store Seafile:
mkdir /home/orgname
cd /home/orgname
wget 'http://seafile.googlecode.com/files/seafile-server_1.8.3_x86-64.tar.gz'
tar -zxvf seafile-server_1.8.3_x86-64.tar.gz
mkdir installed
mv seafile-server_1.8.3_x86-64.tar.gz installed
cd seafile-server_1.8.3
Get all Debian packages and dependencies:
apt-get install mysql-server mysql-client python2.7 python-setuptools python-simplejson python-imaging python-mysqldb python-flup nginx openssl
Lets install Seafile with MySQL server as backend. Follow instructions and fill in the appropriate info:
./setup-seafile-mysql.sh
Let’s create a startip script that controls all Seafile server apps from one place. Save it as ‘/bin/seafile’.
#! /bin/bash SEAFILE=/home/orgname/seafile-server-1.8.3 ulimit -n 30000 case "$@" in start) cd $SEAFILE ./seafile.sh start ./seahub.sh start-fastcgi ;; stop) cd $SEAFILE ./seafile.sh stop ./seahub.sh stop ;; restart) cd $SEAFILE ./seafile.sh stop ./seahub.sh stop ./seafile.sh start ./seahub.sh start-fastcgi ;; gc) cd $SEAFILE ./seafile.sh stop ./seahub.sh stop cd seafile export LD_LIBRARY_PATH=./lib:${LD_LIBRARY_PATH} ./bin/seafserv-gc -c ../../ccnet -d ../../seafile-data ;; *) echo "Usage: /bin/seafile {start|stop|restart|gc}" >&2 exit 1 ;; esac
chmod 755 /bin/seafile
Edit ‘/home/orgname/seahub_settings.py’ and add e-mail server info. In this case we use a smarthost without authentication (ip based access).
EMAIL_USE_TLS = False EMAIL_HOST = 'your.smarthost.com' # smpt server EMAIL_HOST_USER = False # username and domain EMAIL_HOST_PASSWORD = False # password EMAIL_PORT = '25' DEFAULT_FROM_EMAIL = 'yourname@yourdomain.com' SERVER_EMAIL = 'yourname@yourdomain.com'
Now let’s configure Nginx
Edit /etc/nginx/sites-available/default as follows:
server { listen 80; server_name www.yourname.com; rewrite ^/(.*) https://$server_name/$1 permanent; # force redirect http to https } server { listen 443; ssl on; ssl_certificate /etc/nginx/certs/cacert.pem; # path to your cacert.pem ssl_certificate_key /etc/nginx/certs/privkey.pem; # path to your privkey.pem server_name www.yourname.com; location / { fastcgi_pass 127.0.0.1:8000; 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; fastcgi_param HTTP_SCHEME https; access_log /var/log/nginx/seahub.access.log; error_log /var/log/nginx/seahub.error.log; } location /seafhttp { rewrite ^/seafhttp(.*)$ $1 break; proxy_pass http://127.0.0.1:8082; client_max_body_size 0; } location /media { root /home/orgname/seafile-server-1.8.3/seahub; } }
Create certificate folder:
mkdir /etc/nginx/certs
cd /etc/nginx/certs
Create self-signed certificates or use your own at this point:
openssl genrsa -out privkey.pem 2048
openssl req -new -x509 -key privkey.pem -out cacert.pem -days 3652
Nginx is set up, start it:
/etc/init.d/nginx start
Make changes to Seafile to support https:
Modify this line in ‘/home/orgname/ccnet/ccnet.conf’:
SERVICE_URL = https://www.yourdomain.com
Add this line to ‘/home/orgname/seahub_settings.py’:
HTTP_SERVER_ROOT = 'https://www.yourdomain.com/seafhttp'
Start Seafile server services:
seafile start
This is it, point your browser to https://www.yourdomain.com
Good tutorial. Covers almost every step about setting up seafile with MySQL and HTTPS.
Just to clarify: Seahub(the website) is written in Python/Django, but the seafile backend is written in C.
Hi. For Seafile 3.1.5 works the same? Can it be run on Debian 7? They say it was tested only for debian 6.
Great job on the guide!
One note, init script must have descriptive fields like:
#!/bin/sh
### BEGIN INIT INFO
# Provides: seafile
# Required-Start: $network $remote_fs $local_fs
# Required-Stop: $network $remote_fs $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Stop/start seafile
### END INIT INFO
Otherwise, later installations will cause errors.