Seafile Server Manual
Seafile Server Manual
Seafile Server Manual
Seafile is an 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 cannot view a file's contents.
Seafile allows users to create groups with file syncing, wiki, and discussion to enable easy collaboration around
documents within a team.
LICENSE
Seafile and its desktop and mobile clients are published under the GPLv3.
The Seafile server's web end, i.e. Seahub, is published under the Apache License.
About this manual
The "source code" of this manual is hosted on Github https://github.com/haiwen/seafile-docs
Contact information
Twitter: @seafile https://twitter.com/seafile
IRC: #seafile on freenode
Google Group: https://groups.google.com/forum/?fromgroups#!forum/seafile
More Documents
Wiki containing general information of Seafile
Overview
Seafile Components
FAQ
Changelog
Roadmap
Contribution
Components Overview
Seafile server and client consists of several components. Understanding how they work together will save you a lot time
in deploying and maintaining Seafile.
Server
Seahub (django):the website. Seafile server package contains a light-weight Python HTTP server gunicorn that
serves the website. Seahub runs as an application within gunicorn.
FileServer ( fileserver ) (It is called HttpServer before version 3.1): handles raw file upload/download functions for
Seahub. Due to Gunicorn being poor at handling large files, so we wrote this "FileServer" in the C programming
language to serve raw file upload/download.
Seafile server ( seaf-server ):data service daemon
Ccnet server ( ccnet-server ):networking service daemon. In our initial design, Ccnet worked like a traffic bus. All the
network traffic between client, server and internal traffic between different components would go through Ccnet. After
further development we found that file transfer is improved by utilizing the Seafile daemon component directly.
The picture below shows how Seafile desktop client syncs files with Seafile server:
The picture below shows how Seafile mobile client interacts with Seafile server:
The picture below shows how Seafile mobile client interacts with Seafile server if the server is configured behind
Nginx/Apache:
Client
Applet ( seafile-applet ): The GUI front-end
Seafile daemon ( seafile ): data service daemon for client
Ccnet daemon ( ccnet ): networking service daemon for client
Roadmap
Version 3.1 will focus on improving the file syncing algorithm. Including
Platform
Web
First, you can check the ccnet.log in client ( ~/.ccnet/logs/ccnet.log for Linux, C:/users/your_name/ccnet/logs/ccnet.log for
Windows) to see what's wrong.
Possible reasons:
Miss config of SERVICE_URL : Check whether the value of is set correctly in server's ccnet.conf .
Firewall: Ensure the firewall is configured properly. See [[Firewall Settings for Seafile Server ]]
Trouble shooting:
No, You must have python 2.6.5+ or 2.7 installed on your server.
There was an unconfirmed solution on the internet, which later has vanished. (Please explain the installation routine if
you successfully set up Seafile in FreeBSD.)
You can check the back trace in seahub log files('''installation folder/logs/seahub_django_request.log''')
You can also turn on debug by adding DEBUG = True to seahub_settings.py and restart seahub by ./seahub.sh restart ,
then refresh that page, all the debug infomations will be displayed. Make sure ./seahub.sh was started as:
./seahub.sh start-fastcgi
You need to check whether the "avatars" symbolic link under seahub/media/ is correctly link to ../../../seahub-
data/avatars. If not, you need to correct the link according to the "minor upgrade" section in [[Upgrading-Seafile-
Server]]
If your avatars link is correctly linked, and avatars are still broken, you may refresh seahub cache by rm -rf
/tmp/seahub_cache/*
Modify file seafile.ini under ccnet. This file contains the location of seafile-data. Move seafile-data to another place, like
/opt/new/seafile-data . Then modify the file accordingly.
1. Check whether there are some typos in the config, e.g., forget single quote, EMAIL_HOST_USER = XXX, which
should be EMAIL_HOST_USER = 'XXX'
2. Your mail server is not available.
v3.0.4 Server
Previous changelog
changelog of server
changelog of client
changelog of 2-x
Contribution
Licensing
Seafile and its desktop and mobile clients are published under the GPLv3.
The Seafile server's web end, i.e. Seahub, is published under the Apache License.
Discussion
Google Group: https://groups.google.com/forum/?fromgroups#!forum/seafile
In production environment we recommend using MySQL as the database and config Seafile web behing Nginx or
Apache. For those who are not familiar with Nginx and Apache. We recommend Nginx, since it is easier to config than
Apache.
Basic:
Advanced:
Check configuration options for server config options like enabling user registration.
1. Read Seafile Server Components Overview to understand how Seafile server works. This will save you a lot of time.
2. Common Problems for Setting up Server
3. Use our google group forum or IRC to get help.
Upgrade Seafile Server
Upgrade Seafile server
For those that want to package Seafile server
If you want to package seafile yourself, (e.g. for your favorite Linux distribution), you should always use the correspondent
tags:
When we release a new version of seafile client, say 3.0.1, we will add tags v3.0.1 to ccnet, seafile and seafile-client.
Likewise, when we release a new version of seafile server, say 3.0.1, we will add tags v3.0.1-server to ccnet, seafile
and seahub.
For libsearpc, we always use tag v3.0-latest .
Note: The version numbers of each project has nothing to do with the tag name.
Deploying Seafile with SQLite
Generic Linux
Windows
Server for Raspberry Pi
Supposed your organization's name is "haiwen", and you've downloaded seafile-server1.4.0* into your home directory.
We suggest you to layout your deployment as follows :
mkdir haiwen
mv seafile-server_* haiwen
cd haiwen
# after moving seafile-server_* to this directory
tar -xzf seafile-server_*
mkdir installed
mv seafile-server_* installed
# tree . -L 2
.
├── installed
│ └── seafile-server_1.4.0_x86-64.tar.gz
└── seafile-server-1.4.0
├── reset-admin.sh
├── runtime
├── seafile
├── seafile.sh
├── seahub
├── seahub.sh
├── setup-seafile.sh
└── upgrade
We can place all the config files for Seafile server inside "haiwen" directory, making it easier to manage.
When you upgrade to a new version of Seafile, you can simply untar the latest package into "haiwen" directory. In
this way you can reuse the existing config files in "haiwen" directory and don't need to configure again.
Setting Up Seafile Server
Prerequisites
The Seafile server package requires the following packages have been installed in your system
#on Debian
apt-get update
apt-get install python2.7 python-setuptools python-simplejson python-imaging sqlite3
Setup
cd seafile-server-*
./setup-seafile.sh #run the setup script & answer prompted questions
If some of the prerequisites are not installed, the seafile initialization script will ask you to install them.
The script will guide you through the settings of various configuration options.
server ip
The IP address or domain name Seafile client program will access the server with this
or
used by this server address
domain
Seafile stores your data in this The size of this directory will increase as you put more and
seafile
directory. By default it'll be placed in more data into Seafile. Please select a disk partition with
data dir
the current directory. enough free space.
seafile
The TCP port used by Seafile to Default is 12001. If it's been used by other service, you can
server
transfer data set it to another port.
port
fileserver The TCP port used by Seafile Default is 8082. If it's been used by other service, you can
port fileserver set it to another port.
The folder seafile-server-latest is a symbolic link to the current seafile server folder. When later you upgrade to a new
version, the upgrade scripts would update this link to keep it always point to the latest seafile server folder.
Running Seafile Server
Before Running
Since Seafile uses persistent connection between client and server, if you have a large number of clients , you should
increase Linux file descriptors by ulimit before start seafile, like:
ulimit -n 30000
Start seafile:
Start seahub:
Note: The first time you start seahub, the script would prompt you to create an admin account for your seafile server.
After starting the services, you may open a web browser and types
http://192.168.1.111:8000
you will be redirected to the Login page. Enter the username and password you were provided during the Seafile setup.
You will then be returned to the Myhome page where you can create libraries.
Congratulations! Now you have successfully setup your private Seafile server.
If you want to run seahub in a port other than the default 8000, say 8001, you must:
./seahub.sh stop
./seafile.sh stop
modify the value of SERVICE_URL in the file haiwen/ccnet/ccnet.conf , like this: (assume your ip or domain is
192.168.1.100)
SERVICE_URL = http://192.168.1.100:8001
./seafile.sh start
./seahub.sh start 8001
see Seafile Server Configuration Manual for more details about ccnet.conf .
Manage Seafile and Seahub
Stopping
Restarting
./seafile.sh restart
./seahub.sh restart
Most of the time, seafile.sh and seahub.sh work fine. But if they fail, you may
pkill -f seafile-controller
pkill -f "manage.py run_gunicorn"
That's it!
That's it! Now you may want read more about seafile.
Adminintration
Deploying Seafile with MySQL
This manual explains how to setup and run seafile server from a pre-built package with MySQL.
Download
Download the latest server package.
mkdir haiwen
mv seafile-server_* haiwen
cd haiwen
# after moving seafile-server_* to this directory
tar -xzf seafile-server_*
mkdir installed
mv seafile-server_* installed
#tree haiwen -L 2
haiwen
├── installed
│ └── seafile-server_1.8.2_x86-64.tar.gz
└── seafile-server-1.8.2
├── reset-admin.sh
├── runtime
├── seafile
├── seafile.sh
├── seahub
├── seahub.sh
├── setup-seafile.sh
└── upgrade
We can place all the config files for Seafile server inside "haiwen" directory, making it easier to manage.
When you upgrade to a new version of Seafile, you can simply untar the latest package into "haiwen" directory. ''In
this way you can reuse the existing config files in "haiwen" directory and don't need to configure again''.
Prepare MySQL Databases
Three components of Seafile Server need their own databases:
ccnet server
seafile server
seahub
See Seafile Server Components Overview if you want to know more about the seafile server components.
We recommend the first way. The script would ask you for the root password of the mysql server, and it will create:
However, sometimes you have to use the second way. If you don't have the root password, you need someone who has
the privileges, e.g., the database admin, to create the three databases, as well as a mysql user who can access the three
databases for you. For example, to create three databases: ccnet-db / seafile-db / seahub-db for ccnet/seafile/seahub
respectively, and a mysql user "seafile" to access these databases:
Prerequisites
The Seafile server package requires the following packages have been installed in your system
#on Debian/Ubuntu
apt-get update
apt-get install python2.7 python-setuptools python-simplejson python-imaging python-mysqldb
Setup
cd seafile-server-*
./setup-seafile-mysql.sh #run the setup script & answer prompted questions
If some of the prerequisites are not installed, the seafile initialization script will ask you to install them.
You'll see these outputs when you run the setup script
The script will guide you through the settings of various configuration options.
server ip
The IP address or domain name Seafile client program will access the server with this
or
used by this server address
domain
Seafile stores your data in this The size of this directory will increase as you put more and
seafile
directory. By default it'll be placed in more data into Seafile. Please select a disk partition with
data dir
the current directory. enough free space.
seafile
The TCP port used by Seafile to Default is 12001. If it's been used by other service, you can
server
transfer data set it to another port.
port
fileserver The TCP port used by Seafile Default is 8082. If it's been used by other service, you can
port fileserver set it to another port.
At this moment, you will be asked to choose a way to initialize seafile databases:
-------------------------------------------------------
Please choose a way to initialize seafile databases:
-------------------------------------------------------
If you choose "1", you need to provide the root password. The script would create the databases and a new user to
access the databases
If you choose "2", the ccnet/seafile/seahub databases must have already been created, either by you, or someone
else.
If you choose "[1] Create new ccnet/seafile/seahub databases", you would be asked these questions:
mysql server host the host address of the mysql server the default is localhost
password for
the password for the user above
seafile mysql user
If you choose "[2] Use existing ccnet/seafile/seahub databases", you would be asked these questions:
mysql server host the host address of the mysql server the default is localhost
ccnet dabase name the name of the database used by ccnet this database must already exist
#tree haiwen -L 2
haiwen
├── ccnet # configuration files
│ ├── ccnet.conf
│ ├── mykey.peer
│ ├── PeerMgr
│ └── seafile.ini
├── installed
│ └── seafile-server_1.8.2_x86-64.tar.gz
├── seafile-data
│ └── seafile.conf
├── seafile-server-1.8.2 # active version
│ ├── reset-admin.sh
│ ├── runtime
│ ├── seafile
│ ├── seafile.sh
│ ├── seahub
│ ├── seahub.sh
│ ├── setup-seafile.sh
│ └── upgrade
├── seafile-server-latest # symbolic link to seafile-server-1.8.2
├── seahub-data
│ └── avatars
├── seahub_settings.py # optional config file
└── seahub_settings.pyc
The folder seafile-server-latest is a symbolic link to the current seafile server folder. When later you upgrade to a new
version, the upgrade scripts would update this link to keep it always point to the latest seafile server folder.
Running Seafile Server
Before Running
Since Seafile uses persistent connection between client and server, if you have '''a large number of clients ''', you should
increase Linux file descriptors by ulimit before start seafile, like:
ulimit -n 30000
Start seafile:
Start seahub
'''Note:''' The first time you start seahub, the script would prompt you to create an admin account for your seafile server.
After starting the services, you may open a web browser and types
http://192.168.1.111:8000/
you will be redirected to the Login page. Enter the username and password you were provided during the Seafile setup.
You will then be returned to the My Home page where you can create libraries. '''Congratulations!''' Now you have
successfully setup your private Seafile server. #### Run Seahub on another port If you want to run seahub in a port other
than the default 8000, say 8001, you must: * stop the seafile server
./seahub.sh stop
./seafile.sh stop
modify the value of SERVICE_URL in the file haiwen/ccnet/ccnet.conf , like this: (assume your ip or domain is
192.168.1.100 )
SERVICE_URL = http://192.168.1.100:8001
./seafile.sh start
./seahub.sh start 8001
see Seafile server configuration options for more details about ccnet.conf .
Stopping and Restarting Seafile and Seahub
Stopping
Restarting
./seafile.sh restart
./seahub.sh restart
Most of the time, seafile.sh and seahub.sh work fine. But if they fail, you may
pkill -f seafile-controller
pkill -f "manage.py run_gunicorn"
That's it!
That's it! Now you may want read more about seafile.
Prepare
Install python-flup library. On Ubuntu:
Here we deploy Seahub using FastCGI, and deploy FileServer with reverse proxy. We assume you are running Seahub
using domain '''www.myseafile.com'''.
server {
listen 80;
server_name www.myseafile.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;
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/user/haiwen/seafile-server-latest/seahub;
}
}
Nginx settings "client_max_body_size" is by default 1M. Uploading a file bigger than this limit will give you an error
message HTTP error code 413 ("Request Entity Too Large").
You should use 0 to disable this feature or write the same value than for the parameter max_upload_size in section
[fileserver] of /seafile/seafile-data/seafile.conf
Modify ccnet.conf and seahub_setting.py
Modify ccnet.conf
You need to modify the value of SERVICE_URL in /data/haiwen/ccnet/ccnet.conf to let Seafile know the domain you choose.
SERVICE_URL = http://www.myseafile.com
Note: If you later change the domain assigned to seahub, you also need to change the value of SERVICE_URL .
Modify seahub_settings.py
You need to add a line in seahub_settings.py to set the value of FILE_SERVER_ROOT (or HTTP_SERVER_ROOT before version
3.1)
FILE_SERVER_ROOT = 'http://www.myseafile.com/seafhttp'
Start Seafile and Seahub
./seafile.sh start
./seahub.sh start-fastcgi
Notes when Upgrading Seafile Server
When [[upgrading seafile server]], besides the normal steps you should take, there is one extra step to do: '''Update the
path of the static files in your nginx/apache configuration'''. For example, assume your are upgrading seafile server 1.3.0
to 1.4.0, then:
location /media {
root /home/user/haiwen/seafile-server-1.4.0/seahub;
}
Tip: You can create a symbolic link seafile-server-latest , and make it point to your current seafile server folder (Since
seafile server 2.1.0, the setup-seafile.sh script will do this for your). Then, each time you run a upgrade script, it would
update the seafile-server-latest symbolic link to keep it always point to the latest version seafile server folder.
location /media {
root /home/user/haiwen/seafile-server-latest/seahub;
}
This way, you no longer need to update the nginx config file each time you upgrade your seafile server.
Enabling Https with Nginx
Here we use self-signed SSL digital certificate for free. If you use a paid ssl certificate from some authority, just skip the
first step.
If your Nginx does not support SSL, you need to recompile it, the commands are as follows:
Assume you have configured nginx as Deploy-Seafile-with-nginx. To use https, you need to modify your nginx
configuration file.
server {
listen 80;
server_name www.yourdoamin.com;
rewrite ^ https://$http_host$request_uri? permanent; # force redirect http to https
}
server {
listen 443;
ssl on;
ssl_certificate /etc/ssl/cacert.pem; # path to your cacert.pem
ssl_certificate_key /etc/ssl/privkey.pem; # path to your privkey.pem
server_name www.yourdoamin.com;
# ......
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/user/haiwen/seafile-server-latest/seahub;
}
}
Reload Nginx
nginx -s reload
Modify settings to use https
ccnet conf
Since you change from http to https, you need to modify the value of "SERVICE_URL" in ccnet/ccnet.conf :
SERVICE_URL = https://www.yourdomain.com
seahub_settings.py
You need to add a line in seahub_settings.py to set the value of FILE_SERVER_ROOT (Or HTTP_SERVER_ROOT before version
3.1.0)
FILE_SERVER_ROOT = 'https://www.yourdomain.com/seafhttp'
Start Seafile and Seahub
./seafile.sh start
./seahub.sh start-fastcgi
Config Seahub with Apache
Prepare
1. Install python-flup library. On Ubuntu:
On Debian you will need to first enable the non-free repo in /etc/apt/sources.list before you can install libapache2-
mod-fastcgi e.g.:
On Windows, you have to download [mod_fastcgi-*.dll] (http://fastcgi.com/dist/) first, and put it into the modules directory.
On raspbian install fcgi like this
Deploy Seahub/FileServer With Apache
Seahub is the web interface of Seafile server. FileServer is used to handle raw file uploading/downloading through
browsers. By default, it listens on port 8082 for HTTP request.
Here we deploy Seahub using fastcgi, and deploy FileServer with reverse proxy. We assume you are running Seahub
using domain '''www.myseafile.com'''.
First edit your apache config file. Depending on your distro, you will need to add this line to the end of the file:
Note, seahub.fcgi is just a placeholder, you don't need to actually have this file in your system, but be sure to use a path
that is in the DocumentRoot of your Domain/Subdomain to avoid 404 errors.
Second, modify Apache config file: ( sites-enabled/000-default ) for ubuntu/debian ( vhost.conf ) for centos/fedora
<VirtualHost *:80>
ServerName www.myseafile.com
DocumentRoot /var/www
Alias /media /home/user/haiwen/seafile-server-latest/seahub/media
RewriteEngine On
<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]
#
# seahub
#
RewriteRule ^/(media.*)$ /$1 [QSA,L,PT]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /seahub.fcgi$1 [QSA,L,E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</VirtualHost>
If you are running Apache 2.2 then you will need to update your access control configuration accordingly e.g.
<Location /media>
Order allow,deny
Allow from all
</Location>
Modify ccnet.conf and seahub_setting.py
Modify ccnet.conf
You need to modify the value of SERVICE_URL in /data/haiwen/ccnet/ccnet.conf to let Seafile know the domain you choose.
SERVICE_URL = http://www.myseafile.com
Note: If you later change the domain assigned to seahub, you also need to change the value of SERVICE_URL .
Modify seahub_settings.py
You need to add a line in seahub_settings.py to set the value of FILE_SERVER_ROOT (or HTTP_SERVER_ROOT before version
3.1)
FILE_SERVER_ROOT = 'http://www.myseafile.com/seafhttp'
Start Seafile and Seahub
Tip: You can create a symbolic link seafile-server-latest , and make it point to your current seafile server folder (Since
seafile server 2.1.0, the setup-seafile.sh script will do this for your). Then, each time you run a upgrade script, it would
update the seafile-server-latest symbolic link to keep it always point to the latest version seafile server folder.
location /media {
root /home/user/haiwen/seafile-server-latest/seahub;
}
This way, you no longer need to update the apache config file each time you upgrade your seafile server.
Detailed explanation
This may help you understand seafile server better: Seafile Components
There are two components in Seafile server, Seahub and FileServer. FileServer only servers for raw file
uploading/downloading, it listens on 8082. Seahub that serving all the other pages, is still listen on 8000. But under https,
Seahub should listen as in fastcgi mode on 8000 (run as ./seahub.sh start-fastcgi). And as in fastcgi mode, when you visit
http://domain:8000 directly, it should return an error page.
When a user visit https://domain.com/home/my/, Apache receives this request and sends it to Seahub via fastcgi. This is
controlled by the following config items:
#
# seahub
#
RewriteRule ^/(media.*)$ /$1 [QSA,L,PT]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^/(seahub.*)$ /seahub.fcgi/$1 [QSA,L,E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
and
When a user click a file download link in Seahub, Seahub reads the value of FILE_SERVER_ROOT and redirects the user to
address https://domain.com/seafhttp/xxxxx/ . https://domain.com/seafhttp is the value of FILE_SERVER_ROOT . Here, the
FILE_SERVER means the FileServer component of Seafile, which only serves for raw file downloading/uploading.
When Apache receives the request at 'https://domain.com/seafhttp/xxxxx/', it proxies the request to FileServer, which is
listening at 127.0.0.1:8082. This is controlled by the following config items:
ServerName www.myseafile.com
DocumentRoot /var/www
Alias /media /home/user/haiwen/seafile-server-latest/seahub/media
SSLEngine On
SSLCertificateFile /path/to/cacert.pem
SSLCertificateKeyFile /path/to/privkey.pem
RewriteEngine On
#
# seafile fileserver
#
ProxyPass /seafhttp http://127.0.0.1:8082
ProxyPassReverse /seafhttp http://127.0.0.1:8082
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}]
Modify settings to use https
ccnet conf
Since you change from http to https, you need to modify the value of "SERVICE_URL" in ccnet/ccnet.conf :
SERVICE_URL = https://www.myseafile.com
seahub_settings.py
You need to add a line in seahub_settings.py to set the value of FILE_SERVER_ROOT (Or HTTP_SERVER_ROOT before version
3.1.0)
FILE_SERVER_ROOT = 'https://www.myseafile.com/seafhttp'
Start Seafile and Seahub
./seafile.sh start
./seahub.sh start-fastcgi
Detailed explanation
The picture at the end of this document may help you understand seafile server better
There are two components in Seafile server, Seahub and FileServer. FileServer only servers for raw file
uploading/downloading, it listens on 8082. Seahub, that serving all the other pages, is still listen on 8000. But under
https, Seahub should listen as in fastcgi mode on 8000 (run as ./seahub.sh start-fastcgi). And as in fastcgi mode, when
you visit http://domain:8000 directly, it should return an error page.
When a user visit https://domain.com/home/my/, Apache receives this request and sends it to Seahub via fastcgi. This is
controlled by the following config items:
#
# seahub
#
RewriteRule ^/(media.*)$ /$1 [QSA,L,PT]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^/(seahub.*)$ /seahub.fcgi/$1 [QSA,L,E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
and
When a user click a file download link in Seahub, Seahub reads the value of FILE_SERVER_ROOT and redirects the user to
address https://domain.com/seafhttp/xxxxx/ . https://domain.com/seafhttp is the value of FILE_SERVER_ROOT. Here, the
FILE_SERVER means the FileServer component of Seafile, which only serves for raw file downloading/uploading.
When Apache receives the request at 'https://domain.com/seafhttp/xxxxx/', it proxies the request to FileServer, which is
listening at 127.0.0.1:8082. This is controlled by the following config items:
Seafile will find a user both from database and LDAP. LDAP will be tried first. Note that the Seafile admin account created
during setup is always stored in sqlite/mysql database.
Connect to LDAP/AD from Linux
To use LDAP to authenticate user, please add the following lines to ccnet.conf
[LDAP]
# LDAP URL for the host, ldap://, ldaps:// and ldapi:// are supported
# To use TLS, you should configure the LDAP server to listen on LDAPS
# port and specify ldaps:// here.
HOST = ldap://ldap.example.com
# base DN from where all the users can be reached.
BASE = ou=users,dc=example,dc=com
# LDAP admin user DN to bind to. If not set, will use anonymous login.
USER_DN = cn=seafileadmin,dc=example,dc=com
# Password for the admin user DN
PASSWORD = secret
# The attribute to be used as user login id.
# By default it's the 'mail' attribute.
LOGIN_ATTR = mail
[LDAP]
HOST = ldap://192.168.1.123/
BASE = ou=users,dc=example,dc=com
USER_DN = cn=admin,dc=example,dc=com
PASSWORD = secret
LOGIN_ATTR = mail
[LDAP]
HOST = ldap://192.168.1.123/
BASE = cn=users,dc=example,dc=com
USER_DN = cn=admin,cn=users,dc=example,dc=com # or use [email protected] etc
PASSWORD = secret
LOGIN_ATTR = mail
If you're using Active Directory but don't have email address for the users, you can use the following config:
[LDAP]
HOST = ldap://192.168.1.123/
BASE = cn=users,dc=example,dc=com
USER_DN = cn=admin,cn=users,dc=example,dc=com # or use [email protected] etc
PASSWORD = secret
LOGIN_ATTR = userPrincipalName
The userPrincipalName is an user attribute provided by AD. It's usually of the form username@domain-name , where
username is Windows user login name. The the user can log in to seahub with username@domain-name , such as
[email protected] . Note that such login name is not actually an email address. So sending emails from seahub
won't work with this setting.
Connect to LDAP/AD from Windows server
The config syntax on Windows is slightly different from Linux. You should not add ldap:// prefix to the HOST field.
To use LDAP to authenticate user, please add the following lines to ccnet.conf
[LDAP]
# You can optionally specify the port of LDAP/AD server in the HOST field
HOST = ldap.example.com[:port]
# Default 'false'. Set to true if you want Seafile to communicate with the LDAP server via SSL connection.
USE_SSL = true | false
# base DN from where all the users can be reached.
BASE = ou=users,dc=example,dc=com
# LDAP admin user DN to bind to. If not set, will use anonymous login.
USER_DN = cn=seafileadmin,dc=example,dc=com
# Password for the admin user DN
PASSWORD = secret
# The attribute to be used as user login id.
# By default it's the 'mail' attribute.
LOGIN_ATTR = mail
[LDAP]
HOST = 192.168.1.123
BASE = ou=users,dc=example,dc=com
USER_DN = cn=admin,dc=example,dc=com
PASSWORD = secret
LOGIN_ATTR = mail
[LDAP]
HOST = 192.168.1.123
BASE = cn=users,dc=example,dc=com
USER_DN = cn=admin,cn=users,dc=example,dc=com # or use [email protected] etc
PASSWORD = secret
LOGIN_ATTR = mail
If you're using Active Directory but don't have email address for the users, you can use the following config:
[LDAP]
HOST = 192.168.1.123
BASE = cn=users,dc=example,dc=com
USER_DN = cn=admin,cn=users,dc=example,dc=com # or use [email protected] etc
PASSWORD = secret
LOGIN_ATTR = userPrincipalName
The userPrincipalName is an user attribute provided by AD. It's usually of the form username@domain-name , where
username is Windows user login name. The the user can log in to seahub with username@domain-name , such as
[email protected] . Note that such login name is not actually an email address. So sending emails notifications from
Seahub won't work with this setting.
Multiple base DN/Additional search filter
Multiple base DN is useful when your company has more than one OUs to use Seafile. You can specify a list of base DN
in the "BASE" config. The DNs are separated by ";", e.g.
cn=developers,dc=example,dc=com;cn=marketing,dc=example,dc=com
Search filter is very useful when you have a large organization but only a portion of people want to use Seafile. The filter
can be given by setting "FILTER" config. For example, add the following line to LDAP config:
FILTER = memberOf=CN=group,CN=developers,DC=example,DC=com
Note that the cases in the above example is significant. The memberOf attribute is only available in Active Directory.
FILTER = &(!(UserAccountControl:1.2.840.113556.1.4.803:=2))
Known Issues
This is because the pre-compiled package is built on CentOS. The libldap we distribute is from CentOS so it search for
config files on /etc/openldap/ldap.conf. But Ubuntu/Debian uses /etc/ldap/ldap.conf. So the path to the CA files can't be
found on the client.
For Ubuntu
On Ubuntu, we make use of the /etc/init.d/ scripts to start seafile/seahub at system boot.
The content of this script is: (You need to modify the value of user and seafile_dir accordingly)
#!/bin/bash
case "$1" in
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 ${fastcgi_port} >> ${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 ${fastcgi_port} >> ${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
Note: If you want to start seahub in fastcgi, just change the fastcgi variable to true
mkdir /path/to/seafile/dir/logs
pre-start script
/etc/init.d/seafile-server start
end script
post-stop script
/etc/init.d/seafile-server stop
end script
pre-start script
/etc/init.d/seafile-server start
end script
post-stop script
/etc/init.d/seafile-server stop
end script
Done
Don't forget to update the value of script_path later if you update your seafile server.
For other Debian based Linux
The content of this script is: (You need to modify the value of user and script_path accordingly)
#!/bin/sh
case "$1" in
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 ${fastcgi_port} >> ${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 ${fastcgi_port} >> ${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
Note:
1. If you want to start seahub in fastcgi, just change the fastcgi variable to true
2. If you deployed Seafile with MySQL, append "mysql" to the Required-Start line:
mkdir /path/to/seafile/dir/logs
Done
Don't forget to update the value of script_path later if you update your seafile server.
For RHEL/CentOS
On RHEL/CentOS, the script /etc/rc.local is executed by the system at bootup, so we start seafile/seahub there.
In /etc/rc.local, add the directory of python2.6(2.7) to PATH, and add the seafile/seahub start command
`
# Assume the python 2.6(2.7) executable is in "/usr/local/bin"
PATH=$PATH:/usr/local/bin/
Note: If you want to start seahub in fastcgi, just change the "seahub.sh start" in the last line above to "seahub.sh start-
fastcgi"
Done. Don't forget to update the value of script_path later if you update your seafile server.
For RHEL/CentOS run as service
On RHEL/CentOS , we make use of the /etc/init.d/ scripts to start seafile/seahub at system boot as service.
# Set the port of fastcgi, default is 8000. Change it if you need different.
fastcgi_port=8000
#
# chkconfig: - 68 32
# description: seafile
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
}
exit $RETVAL
#
# chkconfig: - 69 31
# description: seahub
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 seafile: "
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
}
exit $RETVAL
[Unit]
Description=Seafile
# add mysql.service or postgresql.service depending on your database to the line below
After=network.target
[Service]
Type=oneshot
ExecStart=${seafile_dir}/seafile-server-latest/seafile.sh start
ExecStop=${seafile_dir}/seafile-server-latest/seafile.sh stop
RemainAfterExit=yes
User=seafile
Group=seafile
[Install]
WantedBy=multi-user.target
[Unit]
Description=Seafile hub
After=network.target seafile.service
[Service]
# change start to start-fastcgi if you want to run fastcgi
ExecStart=${seafile_dir}/seafile-server-latest/seahub.sh start
ExecStop=${seafile_dir}/seafile-server-latest/seahub.sh stop
User=seafile
Group=seafile
Type=oneshot
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
You need to create this service file only if you have seafile console client and you want to run it on system boot.
[Unit]
Description=Seafile client
# Uncomment the next line you are running seafile client on the same computer as server
# After=seafile.service
# Or the next one in other case
# After=network.target
[Service]
Type=oneshot
ExecStart=/usr/bin/seaf-cli start
ExecStop=/usr/bin/seaf-cli stop
RemainAfterExit=yes
User=seafile
Group=seafile
[Install]
WantedBy=multi-user.target
Done
Firewall settings
By default, you should open 4 ports in your firewall settings.
|
| Seahub
| 8000
|-
| FileServer
| 8082
|-
| Ccnet Daemon
| 10001
|-
| Seafile Daemon
| 12001
|
If you run Seafile behind Nginx/Apache with HTTPS, you should open ports
|
| HTTPS
| 443
|-
| Ccnet Daemon
| 10001
|-
| Seafile Daemon
| 12001
|
Set up logrotate for server
How it works
seaf-server and ccnet-server now (since version 3.1) support reopenning logfile by receiving SIGUR1 signal.
This feature is very useful when you need cut logfile while you don't want to shutdown the server programs. All you need
to do now is cutting the logfile on the fly.
NOTE: signal is not supported by windows, so the feature is not available in windows
Default logrotate configuration directory
For debian, the default directory for logrotate should be /etc/logrotate.d/
Sample configuration
Assuming your ccnet-server's logfile is /home/haiwen/logs/ccnet.log , and your ccnet-server's pidfile for ccnet-server is
/home/haiwen/pids/ccnet.pid .
Assuming your seaf-server's logfile is setup to /home/haiwen/logs/seaf-server.log , and your seaf-server's pidfile for seaf-
server is setup to /home/haiwen/pids/seaf-server.pid :
/home/haiwen/logs/seaf-server.log
{
daily
missingok
rotate 52
compress
delaycompress
notifempty
sharedscripts
postrotate
[ ! -f /home/haiwen/pids/seaf-server.pid ] || kill -USR1 `cat /home/haiwen/pids/seaf-server.pid`
endscript
}
/home/haiwen/logs/ccnet.log
{
daily
missingok
rotate 52
compress
delaycompress
notifempty
sharedscripts
postrotate
[ ! -f /home/haiwen/pids/ccnet.pid ] || kill -USR1 `cat /home/haiwen/pids/ccnet.pid`
endscript
}
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
'LOCATION': '127.0.0.1:11211',
}
}
Deploy Seafile behind NAT
A lot of people want to deploy a seafile server in their LAN, and access it from the WAN.
Table of Contents
Login to the web adminstration page of your router. If you don't know how to do this, you should find the instructions
on the manual of the router. If you have no maunal, just google "XXX router administration page" where XXX is
your router's brand.
Navigate around in the adminstration page, and check if there is a tag which contains a word such as "forward",
"advanced". If your router supports it, chances are that you can find the port forwarding related settings there.
Seafile server is composed of several components. You need to configure port forward for all the components listed
below.
ccnet 10001
seaf-server 12001
fileserver 8082
seahub 8000
You don't need to open port 8000 and 8082 if you deploy Seafile behind Apache/Nginx.
If you're not using the default ports, you should adjust the table accroding to your own customiztion.
After you have set the port forwarding rules on your router, you can check whether it works by:
If your port forwarding is working, the command above should succeed. Otherwise, you may get a message saying
something like connection refused or connection timeout.
Set SERVICE_URL
"SERVICE_URL" in ccnet.conf is used to generate the download/upload link for files when you browse files online. Set it
using your WAN IP.
Having done all the steps above, you should be able to visit your seahub server outside your LAN by your WAN IP. But
for most people, the WAN IP address is likey to change regularly by their ISP(Internet Serice Provider), which makes this
approach impratical.
You can use a dynamic DNS(DDNS) Service to overcome this problem. By using a dynamic DNS service, you can visit
your seahub by domain name (instead of by IP), and the domain name will always be mapped to your WAN IP address,
even if it changes regularly.
There are a dozen of dynmaic DNS service providers on the internet. If you don't know what service to choose We
recommend using www.noip.com since it performs well in our testing.
The detailed process is beyond the scope of this wiki. But basically, you should:
Note: We assume you have read [[Deploy Seafile with nginx]] or [[Deploy Seafile with apache]].
Deploy with Nginx
First, we need to overwrite some variables in seahub_settings.py:
SERVE_STATIC = False
MEDIA_URL = '/seafmedia/'
SITE_ROOT = '/seafile/'
We will use Nginx to serve static files(js, css, etc), so we just disable SERVE_STATIC .
MEDIA_URL can be anything you like, just make sure a trailing slash is appended at the end.
We deploy Seafile at /seafile/ directory instead of root directory, so we set SITE_ROOT to /seafile/ .
server {
listen 80;
server_name www.example.com;
location /seafile {
fastcgi_pass 127.0.0.1:8000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_script_name;
location /seafhttp {
rewrite ^/seafhttp(.*)$ $1 break;
proxy_pass http://127.0.0.1:8082;
client_max_body_size 0;
}
location /seafmedia {
rewrite ^/seafmedia(.*)$ /media$1 break;
root /home/user/haiwen/seafile-server-latest/seahub;
}
}
After that, you need to configure your Apache, here is the sample configuration:
ServerName www.example.com
DocumentRoot /var/www
Alias /seafmedia /home/user/haiwen/seafile-server-2.0.2/seahub/media
RewriteEngine On
#
# seafile fileserver
#
ProxyPass /seafhttp http://127.0.0.1:8082
ProxyPassReverse /seafhttp http://127.0.0.1:8082
RewriteRule ^/seafhttp - [QSA,L]
#
# seahub
#
RewriteRule ^/(seafmedia.*)$ /$1 [QSA,L,PT]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^/(seafile.*)$ /seahub.fcgi/$1 [QSA,L,E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
We use Alias to let Apache serve static files, please change the second argument to your path.
Modify ccnet.conf and seahub_setting.py
Modify ccnet.conf
You need to modify the value of SERVICE_URL in /data/haiwen/ccnet/ccnet.conf to let Seafile know the domain you choose.
SERVICE_URL = http://www.myseafile.com/seafile
Note: If you later change the domain assigned to seahub, you also need to change the value of SERVICE_URL .
Modify seahub_settings.py
FILE_SERVER_ROOT = 'http://www.myseafile.com/seafhttp'
Start Seafile and Seahub
./seafile.sh start
./seahub.sh start-fastcgi
Migrate From SQLite to MySQL
First make sure the python module for MySQL is installed. On Ubuntu, use apt-get install python-mysqldb to install it.
2. Download sqlite2mysql.sh and sqlite2mysql.py to the top directory of your Seafile installation path. For example,
/data/haiwen.
3. Run sqlite2mysql.sh
chmod +x sqlite2mysql.sh
./sqlite2mysql.sh
[Database]
ENGINE=mysql
HOST=127.0.0.1
USER=root
PASSWD=root
DB=ccnet-db
CONNECTION_CHARSET=utf8
[database]
type=mysql
host=127.0.0.1
user=root
password=root
db_name=seafile-db
CONNECTION_CHARSET=utf8
Append following lines to seahub_settings.py :
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'USER' : 'root',
'PASSWORD' : 'root',
'NAME' : 'seahub-db',
'HOST' : '127.0.0.1',
'OPTIONS': {
"init_command": "SET storage_engine=INNODB",
}
}
}
First, you can check the ccnet.log in client (~/.ccnet/logs/ccnet.log for Linux, C:/users/your_name/ccnet/logs/ccnet.log for
Windows) to see what's wrong.
Possible reasons:
Firewall: Ensure the firewall is configured properly. See [[Firewall Settings for Seafile Server ]]
Trouble shooting:
Make sure you use "FastCGIExternalServer /var/www/seahub.fcgi -host 127.0.0.1:8000" in httpd.conf or apache2.conf,
especially the "/var/www/seahub.fcgi" part.
Seafile with Apache / HTTPS has text only (no CSS formatting / images)
The media folder (Alias location identified in /etc/apache2/sites-enabled/000-default (Ubuntu) has inappropriate
permissions
Solutions:
Seafile uses Django 1.5, which requires Python 2.6.5+. Make sure your Python version >= 2.6.5.
Seafile
Upgrade Manual
This page is for users who use the pre-compiled seafile server package.
If you build seafile server from source, please read the Upgrading Seafile Server section on that page, instead of
this one.
After upgrading, you may need to clean seahub cache if it doesn't behave as expect.
Major version upgrade (like from 2.x to 3.y)
Suppose you are using version 2.1.0 and like to upgrade to version 3.1.0. First download and extract the new version.
You should have a directory layout similar to this:
haiwen
-- seafile-server-2.1.0
-- seafile-server-3.1.0
-- ccnet
-- seafile-data
cd haiwen/seafile-server-2.1.0
./seahub.sh stop
./seafile.sh stop
cd haiwen/seafile-server-3.1.0
ls upgrade/upgrade_*
...
upgrade/upgrade_2.0_2.1.sh
upgrade/upgrade_2.1_2.2.sh
upgrade/upgrade_2.2_3.0.sh
upgrade/upgrade_3.0_3.1.sh
3. Start from you current version, run the script one by one
upgrade/upgrade_2.1_2.2.sh
upgrade/upgrade_2.2_3.0.sh
upgrade/upgrade_3.0_3.1.sh
cd haiwen/seafile-server-3.1.0/
./seafile.sh start
./seahub.sh start
Minor version upgrade (like from 3.0.x to 3.2.y)
Suppose you are using version 3.0.0 and like to upgrade to version 3.2.2. First download and extract the new version.
You should have a directory layout similar to this:
haiwen
-- seafile-server-3.0.0
-- seafile-server-3.2.2
-- ccnet
-- seafile-data
cd haiwen/seafile-server-3.0.0
./seahub.sh stop
./seafile.sh stop
cd haiwen/seafile-server-3.2.2
ls upgrade/upgrade_*
...
upgrade/upgrade_2.2_3.0.sh
upgrade/upgrade_3.0_3.1.sh
upgrade/upgrade_3.1_3.2.sh
3. Start from you current version, run the script one by one
upgrade/upgrade_3.0_3.1.sh
upgrade/upgrade_3.1_3.2.sh
cd haiwen/seafile-server-3.2.2/
./seafile.sh start
./seahub.sh start
Tiny upgrade (like from 3.1.0 to 3.1.2)
Minor upgrade is like an upgrade from 3.1.0 to 3.1.2.
cd seafile-server-3.1.2
upgrade/minor-upgrade.sh
4. If the new version works file, the old version can be removed
rm -rf seafile-server-3.1.0
Deploy with Windows
For more information on Seafile server, check the documents on Seafile Linux version
Server Administration
Garbage Collecting Unused Blocks on Seafile Server
Common Issues
If you failed to set up Seafile server, first check seafserv-applet.log.
Check whether your Python and the PATH for Python is correctly set.
Put Seafile server package in a simple path, like C:\seafile-packages .
Use python 2.7.4 32bit. If you have installed other python version, uninstall it and install python 2.7.4. Restart seafile
server to see whether the problem has gone.
Delete non-ASCII keys from the registry path HKEY_CLASSES_ROOT\MIME\Database\Content Type, and try again.
Download and Setup Seafile Windows Server
Download/Uncompress
C:\SeafileProgram
|__ seafile-server-1.7.0
Start/Initialization
Go to the folder C:\SeafileProgram\seafile-server-1.7.0\ , and double click run.bat to start Seafile Server. You should notice a
seafile icon appears in the system tray. Choose a disk to store Seafile Server data
Now you'll be prompted a dialog to choose a disk to store the data of seafile server
Right click the tray icon of Seafile Server, choose Add an admin. Input your admin username and password in the
prompted dialog.
If the operation is successful, the tray icon would show a bubble saying Successully added the admin acount
Right click the tray icon, choose Open seafile-server folder. Your seafile-server data folder would be opened.
Edit the file ccnet/ccnet.conf . Modify two lines of ccnet.conf :
NAME = XXXXX
SERVICE_URL = XXX
Change the value of NAME to the name of your Seafile Server, such as NAME = my-company-seafile. This name
would be displayed on your seafile clients
Change the value of SERVICE_URL to http://<your ip address>:8000 . Say the ip address of your windows server is
192.168.1.100, then change it to SERVICE_URL = http://192.168.1.100:8000
After the edit, right click tray icon, choose Restart seafile
Visit Seahub
Open your browser, and visit http://127.0.0.1:8000 . Login with the admin account. If you can login, the initialization is
successful. Configuration done
Seafile Server configuration is finished. See Seafile Client Manual for how to use the client
Preparation
Download and Setup Seafile Windows Server
Stop seafile windows server
Right click the seafile server tray icon
Choose "Quit and shutdown Seafile Server"
[Database]
ENGINE=mysql
HOST=localhost
USER=seafile
PASSWD=seafile
DB=ccnet-db
[database]
type=mysql
host=localhost
user=seafile
password=seafile
db_name=seafile-db
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME' : 'seahub-db',
'USER' : 'seafile',
'PASSWORD' : 'seafile',
'HOST' : 'localhost',
}
}
[DATABASE]
type=mysql
username=seafile
password=seafile
name=seahub-db
host=127.0.0.1
port=3306
Open a window command line prompt, and execute the following command:
Preparation
Install mod_fastcgi
Download [mod_fastcgi-*.dll] (http://fastcgi.com/dist/) first, and put it into the modules/ directory of your Apache
installation.
Note: You must download the right version of mod_fastcgi DLL according for your Apache. For example:
If you are using Apache 2.2, you should download http://fastcgi.com/dist/mod_fastcgi-2.4.6-AP22.dll. The AP22 part
of the dll indicate it's for Apache 2.2.
If you are using Apache 2.0, you should download http://fastcgi.com/dist/old/mod_fastcgi-2.4.2-AP20.dll
Deploy Seahub/FileServer With Apache
Seahub is the web interface of Seafile server. FileServer is used to handle raw file uploading/downloading through
browsers. By default, it listens on port 8082 for HTTP request.
Here we deploy Seahub using fastcgi, and deploy FileServer with reverse proxy. We assume you are running Seahub
using domain '''www.myseafile.com'''.
Edit httpd.conf
First edit your httpd.conf . Add the following lines to the end of the file:
Then add this line (substitute YourDocumentRoot with the value of your apache DocumentRoot )
Note, seahub.fcgi is just a placeholder, you don't need to actually have this file in your system.
<VirtualHost *:80>
ServerName www.myseafile.com
Alias /media "C:/SeafileProgram/seafile-pro-server-2.1.4/seahub/media"
RewriteEngine On
#
# seafile fileserver
#
ProxyPass /seafhttp http://127.0.0.1:8082
ProxyPassReverse /seafhttp http://127.0.0.1:8082
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}]
</VirtualHost>
<Directory "C:/SeafileProgram/seafile-pro-server-2.1.4/seahub/media">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
Modify Configurations
Modify ccnet.conf
SERVICE_URL = http://www.myseafile.com
Note: If you later change the domain assigned to seahub, you also need to change the value of SERVICE_URL .
Modify seafile-data/seafile.conf
[seahub]
port=8000
fastcgi=true
Modify seahub_settings.py
FILE_SERVER_ROOT = 'http://www.myseafile.com/seafhttp'
Notes when Upgrading Seafile Server
When upgrading seafile server, besides the normal steps you should take, there is one extra step to do: '''Update the path
of the static files in your apache configuration'''. For example, assume your are upgrading seafile server 2.1.4 to 2.1.5,
then:
<VirtualHost *:80>
...
Alias /media "C:/SeafileProgram/seafile-pro-server-2.1.5/seahub/media"
...
</VirtualHost>
<Directory "C:/SeafileProgram/seafile-pro-server-2.1.5/seahub/media">
...
</Directory>
Deploy Seafile with Nginx
Here we deploy Seahub using fastcgi, and deploy FileServer with reverse proxy. We assume you are running Seahub
using domain '''www.myseafile.com'''.
server {
listen 80;
server_name www.myseafile.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;
access_log logs/seahub.access.log;
error_log logs/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 C:/SeafileProgram/seafile-pro-server-2.1.4/seahub;
}
}
Modify Configurations
Modify ccnet.conf
SERVICE_URL = http://www.myseafile.com
Note: If you later change the domain assigned to seahub, you also need to change the value of SERVICE_URL .
Modify seafile-data/seafile.conf
[seahub]
port=8000
fastcgi=true
Modify seahub_settings.py
FILE_SERVER_ROOT = 'http://www.myseafile.com/seafhttp'
Notes when Upgrading Seafile Server
When upgrading seafile server, besides the normal steps you should take, there is one extra step to do: '''Update the path
of the static files in your nginx configuration'''. For example, assume your are upgrading seafile server 2.1.0 to 2.1.1, then:
location /media {
root C:/SeafileProgram/seafile-pro-server-2.1.1/seahub;
}
Install Seafile Server as a Windows Service
Install as a service
If the operation succeeds, A dialog would be prompted saying Successully installed seafile service.
If you have installed seafile server as a service, it would run automatically in the background the next time you boot your
system. However, the tray icon would not appear automatically when a user logins in.
To start the tray icon, just doule click the run.bat file in the folder C:\SeafileProgram\seafile-server-1.7.0 Uninstall Seafile
Server Windows service
Right click the seafile server trayicon, choose Open seafile-server folder
Open the folder ccnet under seafile-server folder. The file ccnet.conf is there.
Right click the seafile server trayicon, choose Open seafile-server folder
Open the folder seafile-data under seafile-server folder. The file seafile.conf is there.
In the following section we list the TCP ports used by each of seafile components, as well as how to change them (For
example, some port may have already been used by some other application).
Note: If you change any of the ports, you have to restart seafile server.
ccnet
ccnet is the networking service for seafile server
default: 10001
How to change: Edit the file ccnet.conf. Change the value of PORT under the Network section.
[Network]
PORT = 10001
seaf-server
seaf-server provides the data service for seafile server
default: 12001
How to change: Edit the file seafile.conf . Change the value of port under the network section.
[network]
port=22001
seafile fileserver
default: 8082
How to change: Edit the file seafile.conf . Change the value of port under the fileserver section.
[fileserver]
port=8082
seahub
Note: If you change the port of seahub, you need to change the SERVICE_URL in ccnet.conf .
default: 8000
How to change: Edit the file seafile.conf . Change the value of port under the seahub section. (This is added in Seafile
Windows Server 1.7.0.1)
[seahub]
port=8000
Edit the file ccnet.conf , modify the value of SERVICE_URL accordingly. For example, if you have changed the port to
8001, then modify the value of SERVICE_URL accordingly:
[General]
SERVICE_URL = <Your IP OR DOMAIN>:8001
Upgrading Seafile Windows Server
Minor Upgrade
Major Upgrade
Upgrade Windows Service
C:/SeafileProgram
|______ seafile-server-3.0.0/
Then the first step is to download the new version of Seafile Server and uncompress it to C:/SeafileProgram . After this you
should have:
C:/SeafileProgram
|______ seafile-server-3.0.0/
|______ seafile-server-3.1.0/
Minor upgrade (like upgrade from 3.0.0 to 3.0.1)
Now assume you are upgrading from Seafile Windows Server 3.0.0 to 3.0.1
The avatars folder contains all the avatars uploaded by seafile users.
If you have a user [email protected] , then in this folder, you will find a subfolder [email protected] . This subfolder contains the
avatar pictures of the user [email protected] .
Copy all subfolders like [email protected] to seafile-server-3.0.1/seahub/media/avatars . So that when you start the new seafile
3.0.1 server, these avatars can be load correctly.
Major upgrade (like upgrade from 3.0.0 to 3.1.0)
Now assume you are upgrading from Seafile Windows Server 3.0.x to 3.1.y:
Go to seafile-server-3.1.y/upgrade
Right click the file upgrade_3.0_3.1.bat
If you're using MySQL, you need to manually upgrade the database yourself:
Copy avatars
Run the old version of seafile windows server, right click the tray icon, and choose uninstall windows service in the
menu
Exit the old version of seafile windows server
Start the new version of seafile windows server, right click the tray icon, and choose install as windows service in the
menu
Deploy Seafile Pro Edition
Basic
S3/OpenSwift/Ceph
Config Options
Preparation
On Ubuntu/Debian:
On CentOS/Red Hat:
Note: You can use either the JRE of openJDK or Oracle JRE, but not the GCJ(GNU Java) package.
Install poppler-utils
On Ubuntu/Debian:
On CentOS/Red Hat:
Install Libreoffice/UNO
Libreoffice 4.0+ and Python-uno library are needed to enable office files online preview. If you don't install them, the office
documents online preview will be disabled.
On Ubuntu/Debian:
On Centos/RHEL:
Also, you may need to install fonts for your language, especially for Asians, otherwise the office/pdf document may not
display correctly.
For example, Chinese users may wish to install the WenQuanYi series of truetype fonts:
# For ubuntu/debian
sudo apt-get install ttf-wqy-microhei ttf-wqy-zenhei xfonts-wqy
If you receive an error about "Wheel installs require setuptools >= ...", run this between the pip and boto lines above
Put the license you get under the top level diretory. In our wiki, we use the diretory /data/haiwen/ as the top level directory.
tar xf seafile-pro-server_1.8.0_x86-64.tar.gz
haiwen
├── seafile-license.txt
└── seafile-pro-server-1.8.0/
You should notice the difference between the names of the Community Server and Professional Server. Take the 1.8.0
64bit version as an example:
Seafile Community Server tarball is seafile-server_1.8.0_x86-86.tar.gz ; After uncompressing, the folder is seafile-server-
1.7.0
Seafile Professional Server tarball is seafile-pro-server_1.8.0_x86-86.tar.gz ; After uncompressing, the folder is seafile-
pro-server-1.7.0
Setup
The setup process of Seafile Professional Server is the same as the Seafile Community Server. See Download and
Setup Seafile Server With MySQL.
After you have succesfully setup Seafile Professional Server, you would have a directory layout like this:
#tree haiwen -L 2
haiwen
├── seafile-license.txt # license file
├── ccnet # configuration files
│ ├── ccnet.conf
│ ├── mykey.peer
│ ├── PeerMgr
│ └── seafile.ini
├── pro-data # data specific for professional version
│ └── seafevents.conf
├── seafile-data
│ └── seafile.conf
├── seafile-pro-server-1.8.0
│ ├── reset-admin.sh
│ ├── runtime
│ ├── seafile
│ ├── seafile.sh
│ ├── seahub
│ ├── seahub-extra
│ ├── seahub.sh
│ ├── setup-seafile.sh
│ ├── setup-seafile-mysql.py
│ ├── setup-seafile-mysql.sh
│ └── upgrade
├── seahub-data
│ └── avatars # for user avatars
├── seahub.db
├── seahub_settings.py # seahub config file
Done
At this point, the basic setup of Seafile Professional Server is done.
Restriction
It's quite likely you have deployed the Seafile Community Server and want to switch to the Professional Server, or vice
versa. But there is some restriction:
You can only switch between Community Server and Professional Server of the same minor version.
That is, if you are using Community Server 1.6, and want to switch to the Professional Server 1.7, you must first upgrade
to Community Server 1.7, and then follow the guides below to switch to the Professional Server 1.7. (The last tiny version
number in 1.7.x is not important.)
Preparation
On Ubuntu/Debian:
On CentOS/Red Hat:
Note: You can use either the JRE of openJDK or Oracle JRE, but not the GCJ(GNU Java) package.
Install poppler-utils
On Ubuntu/Debian:
On CentOS/Red Hat:
Install Libreoffice/UNO
Libreoffice program and Python-uno library is needed to enable office files online preview. If you don't install them, the
office documents online preview will be disabled.
On Ubuntu/Debian:
On Centos/RHEL:
Also, you may need to install fonts for your language, especially for Asians, otherwise the office/pdf document may not
display correctly.
For example, Chinese users may wish to install the WenQuanYi series of truetype fonts:
# For ubuntu/debian
sudo apt-get install ttf-wqy-microhei ttf-wqy-zenhei xfonts-wqy
Do the migration
We assume you have already deployed Seafile Community Server 1.8.0 under /data/haiwen/seafile-server-1.8.0 .
Put the license you get under the top level directory of your Seafile installation. In our example, it is /data/haiwen/ .
You should uncompress the tarball to the top level directory of your installation, in our example, /data/haiwen .
tar xf seafile-pro-server_1.8.0_x86-64.tar.gz
haiwen
├── seafile-license.txt
├── seafile-pro-server-1.8.0/
├── seafile-server-1.8.0/
├── ccnet/
├── seafile-data/
├── seahub-data/
├── seahub.db
└── seahub_settings.py
You should notice the difference between the names of the Community Server and Professional Server. Take the 1.8.0
64bit version as an example:
Seafile Community Server tarball is seafile-server_1.8.0_x86-86.tar.gz ; After uncompressing, the folder is seafile-server-
1.8.0
Seafile Professional Server tarball is seafile-pro-server_1.8.0_x86-86.tar.gz ; After uncompressing, the folder is seafile-
pro-server-1.8.0
Do the migration
cd haiwen/seafile-server-1.8.0
./seafile.sh stop
./seahub.sh stop
cd haiwen/seafile-pro-server-1.8.0/
./pro/pro.py setup --migrate
cd haiwen/seafile-pro-server-1.8.0
./seafile.sh start
./seahub.sh start
Switch Back to Community Server
Stop Seafile Professional Server if it's running
cd haiwen/seafile-pro-server-1.8.0/
./seafile.sh stop
./seahub.sh stop
cd haiwen/seafile-server-1.8.0/
./upgrade/minor-upgrade.sh
cd haiwen/seafile-server-1.8.0/
./seafile.sh start
./seahub.sh start
Upgrading Seafile Professional Server
This page is for users who use the pre-compiled seafile server package.
If you build seafile server from source, please read the Upgrading Seafile Server section on that page, instead of
this one.
After upgrading, you may need to clean seahub cache if it doesn't behave as expect.
Major Continuous Upgrade (like from 1.2.x to 1.3.y)
Continuous upgrade means to upgrade from one version of Seafile server to the next version. For example, upgrading
from 1.2.0 to 1.3.0 (or upgrading from 1.2.0 to 1.3.1) is a continuous upgrade.
After downloading and extracting the new version, you should have a directory layout similar to this:
haiwen
-- seafile-server-1.2.0
-- seafile-server-1.3.0
-- ccnet
-- seafile-data
cd haiwen/seafile-server-1.2.0
./seahub.sh stop
./seafile.sh stop
cd haiwen/seafile-server-1.3.0
upgrade/upgrade_1.2_1.3_server.sh
cd haiwen/seafile-server-1.3.0/
./seafile.sh start
./seahub.sh start
Noncontinuous Upgrade (like from 1.1 to 1.3)
You may also upgrade a few versions at once, e.g. from 1.1.0 to 1.3.0. The procedure is:
Just run the upgrade scripts in sequence. (You don't need to download server package 1.2.0)
Minor upgrade (like from 1.5.0 to 1.5.1)
Minor upgrade is like an upgrade from 1.5.0 to 1.5.1.
haiwen
-- seafile-server-1.5.0
-- seafile-server-1.5.1
-- ccnet
-- seafile-data
seafile-server-1.5.0/seahub.sh stop
seafile-server-1.5.0/seafile.sh stop
2. For this type of upgrade, you only need to update the avatar link. We provide a script for you, just run it:
cd seafile-server-1.5.1
upgrade/minor-upgrade.sh
cd ..
seafile-server-1.5.1/seafile.sh start
seafile-server-1.5.1/seahub.sh start
4. If the new version works file, the old version can be removed
rm -rf seafile-server-1.5.0
Setup With Amazon S3
Prepare
To setup Seafile Professional Server with Amazon S3:
Setup the basic Seafile Professional Server following the guide on [[Download and setup Seafile Professional
Server]]
Install the python boto library. It's needed to access S3 service.
Install and configure memcached. For best performance, Seafile requires install memcached and enable memcache
for objects. We recommend to allocate 128MB memory for memcached. Edit /etc/memcached.conf
# Start with a cap of 64 megs of memory. It's reasonable, and the daemon default
# Note that the daemon will grow to this size, but does not start out holding this much
# memory
# -m 64
-m 128
Modify Seafile.conf
Edit /data/haiwen/seafile-data/seafile.conf , add the following lines:
[commit_object_backend]
name = s3
# bucket name can only use lowercase characters, numbers, periods and dashes
bucket = my.commit-objects
key_id = your-key-id
key = your-secret-key
memcached_options = --SERVER=localhost --POOL-MIN=10 --POOL-MAX=100
[fs_object_backend]
name = s3
# bucket name can only use lowercase characters, numbers, periods and dashes
bucket = my.fs-objects
key_id = your-key-id
key = your-secret-key
memcached_options = --SERVER=localhost --POOL-MIN=10 --POOL-MAX=100
[block_backend]
name = s3
# bucket name can only use lowercase characters, numbers, periods and dashes
bucket = my.block-objects
key_id = your-key-id
key = your-secret-key
memcached_options = --SERVER=localhost --POOL-MIN=10 --POOL-MAX=100
It's recommended to create separate buckets for commit, fs, and block objects. The key_id and key are required to
authenticate you to S3. You can find the key_id and key in the "security credentials" section on your AWS account page.
When creating your buckets on S3, please first read S3 bucket naming rules. Note especially not to use UPPERCASE
letters in bucket names (don't use camel style names, such as MyCommitOjbects).
Run and Test
Now you can start Seafile by ./seafile.sh start and ./seahub.sh start and visit the website.
Setup With OpenStackSwift
Starting from professional server 2.0.5, Seafile can use S3-compatible cloud storage (such as OpenStack/Swift) as
backend. This document will use Swift as example.
Seafile Server Preparation
To setup Seafile Professional Server with OpenStack Swift:
Setup the basic Seafile Professional Server following the guide on Download and Setup Seafile Professional Server
Install the python boto library. It's needed to access Swift.
For best performance, Seafile requires install memcached and enable memcache for objects.
# Start with a cap of 64 megs of memory. It's reasonable, and the daemon default
# Note that the daemon will grow to this size, but does not start out holding this much
# memory
# -m 64
-m 128
Swift Preparation
You should enable S3 emulation middleware for Swift. For instructions please refer to the following links:
http://www.buildcloudstorage.com/2011/11/s3-apis-on-openstack-swift.html
http://docs.openstack.org/grizzly/openstack-compute/admin/content/configuring-swift-with-s3-emulation-to-use-
keystone.html
After successfully setup S3 middleware, you should be able to access it with any S3 clients. The access key id is a user in
Swift, and the secret key is the user's password. The next thing you need to do is to create buckets for Seafile. With
Python boto library you can do as follows:
import boto
import boto.s3.connection
connection = boto.connect_s3(
aws_access_key_id='swifttest:testuser',
aws_secret_access_key='testing',
port=8080,
host='swift-proxy-server-address',
is_secure=False,
calling_format=boto.s3.connection.OrdinaryCallingFormat())
connection.create_bucket('seafile-commits')
connection.create_bucket('seafile-fs')
connection.create_bucket('seafile-blocks')
Modify seafile.conf
Append the following lines to seafile-data/seafile.conf
[block_backend]
name = s3
bucket = seafile-blocks
key_id = swifttest:testuser
key = testing
host = <swift-proxy-server-address>:8080
path_style_request = true
memcached_options = --SERVER=localhost --POOL-MIN=10 --POOL-MAX=100
[commit_object_backend]
name = s3
bucket = seafile-commits
key_id = swifttest:testuser
key = testing
host = <swift-proxy-server-address>:8080
path_style_request = true
memcached_options = --SERVER=localhost --POOL-MIN=10 --POOL-MAX=100
[fs_object_backend]
name = s3
bucket = seafile-fs
key_id = swifttest:testuser
key = testing
host = <swift-proxy-server-address>:8080
path_style_request = true
memcached_options = --SERVER=localhost --POOL-MIN=10 --POOL-MAX=100
Run and Test
Now you can start Seafile by ./seafile.sh start and ./seahub.sh start and visit the website.
Setup With Ceph
Ceph is a scalable distributed storage system. Seafile can use Ceph's RADOS object storage layer for storage backend.
Copy ceph conf file and client keyring
Seafile acts as a client to Ceph/RADOS, so it needs to access ceph cluster's conf file and keyring. You have to copy these
files from a ceph admin node's /etc/ceph directory to the seafile machine.
[block_backend]
name = ceph
ceph_config = /etc/ceph/ceph.conf
pool = seafile-blocks
memcached_options = --SERVER=localhost --POOL-MIN=10 --POOL-MAX=100
[commit_object_backend]
name = ceph
ceph_config = /etc/ceph/ceph.conf
pool = seafile-commits
memcached_options = --SERVER=localhost --POOL-MIN=10 --POOL-MAX=100
[fs_object_backend]
name = ceph
ceph_config = /etc/ceph/ceph.conf
pool = seafile-fs
memcached_options = --SERVER=localhost --POOL-MIN=10 --POOL-MAX=100
It's recommended to create separate pools for commit, fs, and block objects.
# Start with a cap of 64 megs of memory. It's reasonable, and the daemon default
# Note that the daemon will grow to this size, but does not start out holding this much
# memory
# -m 64
-m 128
Use arbitary Ceph user
The above configuration will use the default (client.admin) user to connect to Ceph. You may want to use some other
Ceph user to connect. This is supported in Seafile. To specify the Ceph user, you have to add a ceph_client_id option to
seafile.conf, as the following:
[block_backend]
name = ceph
ceph_config = /etc/ceph/ceph.conf
# Sepcify Ceph user for Seafile here
ceph_client_id = seafile
pool = seafile-blocks
memcached_options = --SERVER=localhost --POOL-MIN=10 --POOL-MAX=100
[commit_object_backend]
name = ceph
ceph_config = /etc/ceph/ceph.conf
# Sepcify Ceph user for Seafile here
ceph_client_id = seafile
pool = seafile-commits
memcached_options = --SERVER=localhost --POOL-MIN=10 --POOL-MAX=100
[fs_object_backend]
name = ceph
ceph_config = /etc/ceph/ceph.conf
# Sepcify Ceph user for Seafile here
ceph_client_id = seafile
pool = seafile-fs
memcached_options = --SERVER=localhost --POOL-MIN=10 --POOL-MAX=100
[client.seafile]
keyring = <path to user's keyring file>
Configurable Options
In the file /data/haiwen/pro-data/seafevents.conf :
[INDEX FILES]
## must be "true" to enable search
enabled = true
## The interval the search index is updated. Can be s(seconds), m(minutes), h(hours), d(days)
interval=10m
## If true, index the contents of office/pdf files while updating search index
## Note: If you change this option from "false" to "true", then you need to clear the search index and update the index again. See the FAQ for details.
index_office_pdf=false
[OFFICE CONVERTER]
[SEAHUB EMAIL]
## must be "true" to enable user email notifications when there are new messages
enabled = true
The section above listed all the options in /data/haiwen/pro-data/seafevents.conf . Most of the time you can use the default
settings. But you may want to modify some of them to fit your own use case.
We list them in the following table, as well as why we choose the default value.
default
section option description
value
# Replace default from email with user's email or not, defaults to ``False``
REPLACE_FROM_EMAIL = True
# Set reply-to header to user's email or not, defaults to ``False``. For details,
# please refer to http://www.w3.org/Protocols/rfc822/
ADD_REPLY_TO_HEADER = True
Note:
./seahub.sh restart
Use existing ElasticSearch server
The search module use an elasticsearch server bundled within the seafile pro server tarball. However, you may have an
existing Elasitcsearch server or cluster running in your company. In this situation, you can change the config file to use
your existing ES server or cluster.
Currently the seafile search module use the default analyzer in your ES server settings.
Change the config file
Edit pro-data/seafevents.conf , add settings in the section [INDEX FILES] to specify your ES server host and port:
vim pro-data/seafevents.conf
[INDEX FILES]
...
es_host = 192.168.1.101
es_port = 9500
Search Options
Following options should be set in file seafevents.conf, and need to restart seafile and seahub to take affect.
[INDEX FILES]
...
# Whether search office/pdf files. Defaults to false.
index_office_pdf = true
Following options should be set in file seahub_settings.py, and need to restart seahub to take affect.
# Whether highlight the keywords in the file when the visit is via clicking a link in 'search result' page.
# Defaults to false. Since v3.0.5.
HIGHLIGHT_KEYWORD = True
Common problems
First, make sure you have index_office_pdf = true in the file seafevents.conf:
[INDEX FILES]
...
index_office_pdf = true
If you have not installed pdftotext, you can't extract text from PDF files.
which pdftotext
Run the above command, if there is no output, then you need to install it:
The search index is updated every 10 minutes by default. So before the first index update is performed, you get nothing
no matter what you search.
cd haiwen/seafile-pro-server-2.0.4
./pro/pro.py search --update
This is because the server can't index encrypted files, since, they are encrypted.
Say your files are mainly in German, you can specify it in seafevents.conf :
[INDEX FILES]
...
lang = german
This way, the text of your files can be handled more gracefully when you search them.
Anytime you change the value of lang , you have to delete the search index and recreate it:
Supported languages include: arabic , armenian , basque , brazilian , bulgarian , catalan , chinese , cjk , czech , danish ,
dutch , english , finnish , french , galician , german , greek , hindi , hungarian , indonesian , italian , norwegian , persian ,
portuguese , romanian , russian , spanish , swedish , turkish , thai
Deploy in a cluster
Architecture
The Seafile cluster solution employs a 3-tier architecture:
Load balancer tier: Distribute incoming traffic to Seafile servers. HA can be achieved by deploying multiple load
balancer instances.
Seafile server cluster: a cluster of Seafile server instances. If one instance fails, the load balancer will stop handing
traffic to it. So HA is achieved.
Backend storage: Distributed storage cluster, such as S3, Openstack Swift, Ceph.
This architecture scales horizontally. That is, you can handle more traffic by adding more machines. The architecture is
presented in the following picture.
Preparation
Hardware
First make sure your have installed python 2.6 or 2.7, then:
If you receive an error about "Wheel installs require setuptools >= ...", run this between the pip and boto lines above
Setup Memcached
All seafile server instances will share the same memcached servers. Let's assume that the address of memcached server
is 192.168.1.134, listening on port 11211 (the default).
By default, memcached only listen on 127.0.0.1. So you should modify memcached.conf and restart memcached.
# Specify which IP address to listen on. The default is to listen on all IP addresses
# This parameter is one of the only security measures that memcached has, so make sure
# it's listening on a firewalled interface.
-l 0.0.0.0
It's also recommended to set a higher limit for memcached's memory, such as 256MB.
# Start with a cap of 64 megs of memory. It's reasonable, and the daemon default
# Note that the daemon will grow to this size, but does not start out holding this much
# memory
-m 256
Configure a Single Node
You should make sure the config files on every Seafile server are consistent. It's critical that you don't set up seafile
server on each machine separately. You should set up seafile server on one machine then copy the config
directory to the other machines.
Put the license you get under the top level diretory. In our wiki, we use the diretory /data/haiwen/ as the top level directory.
tar xf seafile-pro-server_2.1.3_x86-64.tar.gz
haiwen
├── seafile-license.txt
└── seafile-pro-server-2.1.3/
The setup process of Seafile Professional Server is the same as the Seafile Community Server. See Download and
Setup Seafile Server With MySQL in the community wiki.
Note: Use the load balancer's address or domain name for the server address. Don't use the local IP address of
each Seafile server machine. This assures the user will always access your service via the load balancers.
After the setup process is done, you still have to do a few manually changes to the config files.
seafile-data/seafile.conf
[cluster]
enabled = true
memcached_options = --SERVER=192.168.1.134 --POOL-MIN=10 --POOL-MAX=100
(Optional) The Seafile server also opens a port for the load balancers to run health checks. Seafile by default use port
11001. You can change this by adding the following config to seafile-data/seafile.conf
[cluster]
health_check_port = 12345
seahub_settings.py
Add following configuration to seahub_settings.py . These settings tell Seahub to store avatar in database and cache
avatar in memcached.
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
'LOCATION': '192.168.1.134:11211',
}
}
AVATAR_FILE_STORAGE = 'seahub.base.database_storage.DatabaseStorage'
pro-data/seafevents.conf
[INDEX FILES]
external_es_server = true
In cluster environment, we have to store avatars in the database instead of in a local disk.
CREATE TABLE `avatar_uploaded` (`filename` TEXT NOT NULL, `filename_md5` CHAR(32) NOT NULL PRIMARY KEY, `data` MEDIUMTEXT NOT NULL, `size` I
You also need to add the settings for backend cloud storage systems to the config files.
Once you have finished configuring this single node, start it to test if it can run correctly:
cd /data/haiwen/seafile-server-latest
./seafile.sh start
./seahub.sh start
Note: The first time you start seahub, the script would prompt you to create an admin account for your seafile server.
Open your browser and visit http://ip-address-of-this-node:8000, login with the admin account.
Configure other nodes
Now you have one node working fine, let's continue to configure other nodes.
Supposed your seafile installation directory is /data/haiwen , compress this whole directory into a tar ball and copy the tar
ball to all other Seafile server machines. You can simply uncompress the tar ball and use it.
For Nginx:
Config Seahub with Nginx
Enabling Https with Nginx
For Apache:
Config Seahub with Apache
Enabling Https with Apache
Firewall Settings
Beside standard ports of a seafile server, there are 2 firewall rule changes for Seafile cluster:
On each Seafile server machine, you should open the health check port (default 11001);
On the memcached server, you should open the port 11211. For security, only the Seafile servers should be allow to
access this port.
Load Balancer Setting
Now that your cluster is already running, fire up the load balancer and welcome your users.
In the AWS ELB management console, after you've added the Seafile server instances to the instance list, you should do
two more configurations.
HAProxy
global
log 127.0.0.1 local1 notice
maxconn 4096
user haproxy
group haproxy
defaults
log global
mode http
retries 3
maxconn 2000
contimeout 5000
clitimeout 50000
srvtimeout 50000
If the above works, the next step would be Enable search and background tasks in a cluster.
Enable search and background tasks in a cluster
In the seafile cluster, only one server should run the background tasks, including:
Let's assume you have three nodes in your cluster, namely A, B, and C, and you decide that:
Install Java
On Ubuntu/Debian:
On CentOS/Red Hat:
Edit pro-data/seafevents.conf
external_es_server = true
In your firewall rules for node A, you should open the port 9500 (for search requests).
Configure Other Nodes
On nodes B and C, you need to:
[INDEX FILES]
external_es_server = true
es_host = <ip of node A>
es_port = 9500
Start the background tasks
On node A (the background tasks node), you can star/stop background tasks by:
How to setup nfs server and client is beyond the scope of this wiki. Here are few references:
Ubuntu: https://help.ubuntu.com/community/SettingUpNFSHowTo
CentOS: http://www.centos.org/docs/5/html/Deployment_Guide-en-US/ch-nfs.html
Supposed your seafile server installation directory is /data/haiwen , after you run the setup script there should be a seafile-
data directory in it. And supposed you mount the NFS drive on /seafile-nfs , you should follow a few steps:
mv /data/haiwen/seafile-data /seafile-nfs/
On every node in the cluster, make a symbolic link to the shared seafile-data folder
cd /data/haiwen
ln -s /seafile-nfs/seafile-data /data/haiwen/seafile-data
This way the instances will share the same seafile-data folder. All other config files and log files will remain independent.
FAQ
This is because the server can't index encrypted files, since, they are encrypted.
I switched to Professional Server from Community Server, but whatever I search, I get no results
The search index is updated every 10 minutes by default. So before the first index update is performed, you get
nothing no matter what you search.
cd haiwen/seafile-pro-server-1.7.0
./pro/pro.py search --update
If you have lots of files, this process may take quite a while.
I want to enable full text search for office/pdf documents, so I set index_office_pdf to true in the configuration file, but it
doesn't work.
cd /data/haiwen/seafile-pro-server-1.7.0/
./seafile.sh restart
How can I change max size and max pages of documents that can be previewed online ?
cd /data/haiwen/seafile-pro-server-1.7.0/
./seafile.sh restart
./seahub.sh restart
Current office online preview works with libreoffice 4.0-4.2. If the version of libreoffice installed by apt-get is too old or too
new, you can solve this by:
tar xf LibreOffice_4.1.6_Linux_x86-64_deb.tar.gz
cd LibreOffice_4.1.6.2_Linux_x86-64_deb
cd DEBS
sudo dpkg -i *.deb
Restart your seafile server and try again. It should work now.
./seafile.sh restart
Seafile Professional Edition Software License Agreement
NOTICE: READ THE FOLLOWING TERMS AND CONDITIONS CAREFULLY BEFORE YOU DOWNLOAD, INSTALL OR USE Seafile, Inc'S PROPRIETARY SOFTWARE. BY IN
1. DEFINITIONS
"Seafile, Inc" means Seafile, Inc
"You and Your" means the party licensing the Software hereunder.
"Software" means the computer programs provided under the terms of this license by Seafile, Inc together with any documentation provided therewith
2. GRANT OF RIGHTS
2.1 General
The License granted for Software under this Agreement authorizes You on a non-exclusive basis to use the Software. The Software is licensed, not sold
* You may use and install the Software on an unlimited number of computers that are owned, leased, or controlled by you.
* Nothing in this Agreement shall permit you, or any third party to disclose or otherwise make available to any third party the licensed Software, sourc
* You agree to indemnify, hold harmless and defend Seafile, Inc from and against any claims or lawsuits, including attorney's fees, that arise as a resul
* You do not permit further redistribution of the Software by Your end-user customers
5. NO DERIVATIVE WORKS
The inclusion of source code with the License is explicitly not for your use to customize a solution or re-use in your own projects or products. The benef
6. OWNERSHIP
You acknowledge that all copies of the Software in any form are the sole property of Seafile, Inc. You have no right, title or interest to any such Softwar
7. CONFIDENTIALITY
You hereby acknowledge and agreed that the Software constitute and contain valuable proprietary products and trade secrets of Seafile, Inc, embodyin
8. DISCLAIMER OF WARRANTIES
EXCEPT AS OTHERWISE SET FORTH IN THIS AGREEMENT THE SOFTWARE IS PROVIDED TO YOU "AS IS", AND Seafile, Inc MAKES NO EXPRESS OR IMPLIED WARR
9. LIMITATION OF LIABILITY
YOU ACKNOWLEDGE AND AGREE THAT THE CONSIDERATION WHICH Seafile, Inc IS CHARGING HEREUNDER DOES NOT INCLUDE ANY CONSIDERATION FOR ASS
10. INDEMNIFICATION
You agree to defend, indemnify and hold Seafile, Inc and its employees, agents, representatives and assigns harmless from and against any claims, pro
11. TERMINATION
Your license is effective until terminated. You may terminate it at any time by destroying the Software or returning all copies of the Software to Seafile
YOU HEREBY ACKNOWLEDGE THAT YOU HAVE READ THIS AGREEMENT, UNDERSTAND IT AND AGREE TO BE BOUND BY ITS TERMS AND CONDITIONS.
Download and Setup Seafile Windows Professional
Server
The following tutorials is special for Windows Professional Server, for more infomation about Seafile Windows Server
please see Deploy Seafile under Windows
Config Options
Configurable Options
Search
Details about File Search
Download and Setup Seafile Windows Professional
Server
Requirements
A windows machine with at least 2GB memory.
Install Java
Download and install Oracle JDK 1.7 from the oracle website
Set the JAVA_HOME enviroment varaible to your java installation path. Fro example, by default you would install java
to C:/program Files/Java/jdk1.7.0_51/ , you shoudl set the value of the JAVA_HOME enviroment variable to C:/program
Files/Java/jdk1.7.0_51/
To ensure you have correctly installed java, open a command line window, and execute these commands:
java -version
2. This command should print the value of the JAVA_HOME environmental variable:
echo %JAVA_HOME%
Install ElasticSearch Server
The search functionality of Seafile Pro depends on elasticsearch.
Uncompress it to a folder. The search index size would increase as your files increase, so please choose a folder
with enough free space)
Install elasticsearch server as a windows service. First, open a command line window. Suppose you have
uncompressed elasticsearch server to D:\
D:\elasticsearch\bin\service.bat install
D:\elasticsearch\bin\service.bat start
Prepare the License File
If you prepare to extract seafile server to C:/SeafileProgram , then you should put the license file you get in the folder
C:/SeafileProgram too.
C:\SeafileProgram
|_______ seafile-pro-server-2.1.4/
|_______ seafile-license.txt
Setup Seafile Server
Except for the Java program and the license, the setup of pro server is the same as setup of community edition. Please
follow the document on setup community edition
Migrate from Seafile Community Server
Restriction
It's quite likely you have deployed the Seafile Windows Community Server and want to switch to the Professional Server,
or vice versa. But there is some restriction:
You can only switch between Community Server and Professional Server of the same version.
That is, if you are using Community Server 2.1.x, and want to switch to the Professional Server 2.2.x, you must first
upgrade to Community Server 2.2.x, and then follow the guides below to switch to the Professional Server 2.2.x.
Preparation
Install Java
Download and install Oracle JDK 1.7 from the oracle website
Set the JAVA_HOME enviroment varaible to your java installation path. Fro example, by default you would install java
to C:/program Files/Java/jdk1.7.0_51/ , you shoudl set the value of the JAVA_HOME enviroment variable to C:/program
Files/Java/jdk1.7.0_51/
To ensure you have correctly installed java, open a command line window, and execute these commands:
java -version
2. This command should print the value of the JAVA_HOME environmental variable:
echo %JAVA_HOME%
Uncompress it to a folder. The search index size would increase as your files increase, so please choose a folder
with enough free space)
Install elasticsearch server as a windows service. First, open a command line window. Suppose you have
uncompressed elasticsearch server to D:\
D:\elasticsearch\bin\service.bat install
D:\elasticsearch\bin\service.bat start
You can download the latest Seafile Professional Server for windows here
Assume you have your seafile community server in C:/SeafileProgram/seafile-server-3.0.4 , you should also uncompress the
professional server to C:\SeafileProgram .
C:\SeafileProgram
|_______ seafile-server-3.0.4/
|_______ seafile-pro-server-3.0.6/
You should notice the difference between the names of the Community Server and Professional Server. Take the 3.0.4
version as an example:
Seafile Community Server tarball is seafile-server_3.0.4_win32_tar.gz ; After uncompressing, the folder is seafile-server-
3.0.0
Seafile Professional Server tarball is seafile-pro-server_3.0.4_win32.tar.gz ; After uncompressing, the folder is seafile-pro-
server-3.0.0
Put the license file you get in the folder C:/SeafileProgram too. You should have:
C:\SeafileProgram
|_______ seafile-server-3.0.4/
|_______ seafile-pro-server-3.0.6/
|_______ seafile-license.txt
Do the migration
If you have installed seafile server as as service, make sure you have uninstalled the service
If the seafile server is running, make sure to stop it by right click on the tray icon and choose "Quit and Stop seafile
server"
Do the migration
You should open the folder C:/SeafileProgram/seafile-pro-server-3.0.1 , and run the migrate_to_pro.bat script as administator.
Now you can start seafile professional server but double clicking run.bat file under C:/SeafileProgram/seafile-pro-server-3.x
Switch Back to Community Server
To switch back to the community server, you need:
[WEBDAV]
port = 8080
Every time the configuration is modified, you need to restart seafile server to make it take effect.
Your WebDAV client would visit the Seafile WebDAV server at http://example.com:8080
[WEBDAV]
enabled = true
port = 8080
fastcgi = false
share_name = /
Your WebDAV client would visit the Seafile WebDAV server at http://example.com/seafdav
[WEBDAV]
enabled = true
port = 8080
fastcgi = true
share_name = /seafdav
In the above config, the value of share_name is changed to /seafdav, which is the address suffix you assign to seafdav
server.
Nginx
access_log logs/seafdav.access.log;
error_log logs/seafdav.error.log;
}
Apache
First edit httpd.conf file, add this line to the end of the file: (substitute YourDocumentRoot with the value of your apache
DocumentRoot )
<VirtualHost *:80>
ServerName www.myseafile.com
Alias /media "C:/SeafileProgram/seafile-pro-server-2.1.4/seahub/media"
RewriteEngine On
#
# seafile fileserver
#
ProxyPass /seafhttp http://127.0.0.1:8082
ProxyPassReverse /seafhttp http://127.0.0.1:8082
RewriteRule ^/seafhttp - [QSA,L]
#
# seafile webdav
#
RewriteCond %{HTTP:Authorization} (.+)
RewriteRule ^(/seafdav.*)$ /seafdav.fcgi$1 [QSA,L,e=HTTP_AUTHORIZATION:%1]
RewriteRule ^(/seafdav.*)$ /seafdav.fcgi$1 [QSA,L]
#
# seahub
#
RewriteRule ^/(media.*)$ /$1 [QSA,L,PT]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /seahub.fcgi$1 [QSA,L,E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</VirtualHost>
<Directory "C:/SeafileProgram/seafile-pro-server-2.1.4/seahub/media">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
Notes on Clients
Windows
On Windows it is recommended to use a webdav client software such as Cyberduck or BitKinex. The implementation of
webdav support in Windows explorer is not very usable since:
Windows explorer requires to use HTTP digest authentication. But Seafile can't support this because it doesn't store
plain text passwords on the server.
HTTP basic authentication is only supported for HTTPS (which is reasonable). But explorer doesn't accept self-
signed certificates.
The conclusion is if you have a valid ssl certificate, you should be able to access seafdav from Windows explorer.
Otherwise you should use a client software. It's also reported that Windows XP doesn't support HTTPS webdav.
Linux
On Linux you have more choices. You can use file manager such as Nautilus to connect to webdav server. Or you can
use davfs2 from the command line.
To use davfs2
The -o option sets the owner of the mounted directory to so that it's writable for non-root users.
It's recommended to disable LOCK operation for davfs2. You have to edit /etc/davfs2/davfs2.conf
use_locks 0
Mac OS X
Finder's support for WebDAV is also not very stable and slow. So it is recommended to use a webdav client software such
as Cyberduck.
Frequently Asked Questions
By default, seafdav is disabled. Check whether you have enabled = true in seafdav.conf . If not, modify it and restart seafile
server.
If you deploy SeafDAV behind Nginx/Apache, make sure to change the value of share_name as the sample configuration
above. Restart your seafile server and try again.
Configurable Options
In the file X:/seafile-server/pro-data/seafevents.conf (where X is the drive you choose during Seafile Server initialization.)
[INDEX FILES]
# must be "true" to enable search
enabled = true
# The interval the search index is updated. Can be s(seconds), m(minutes), h(hours), d(days)
interval=10m
# If true, index the contents of office files while updating search index
# Note: If you change this option from "false" to "true", then you need to clear the search index and update the index again. See the FAQ for details.
index_office_pdf=false
[SEAHUB EMAIL]
# must be "true" to enable user email notifications when there are new messages
enabled = true
Config Files
This section explains how to change various config options for Seafile server.
User management
[General]
# This is the name of this Seafile server. Currenlty it is only used in Seafile client's log.
NAME=example
[Network]
# Ccnet waits for client connections on this port. If it's used by other services, please change it.
# This is only useful for the seafile server.
PORT=10001
[Client]
# Start from version 3.1.2, this option is not used in Linux server and client. Unix socket is used instead.
# Ccnet listens to this port on localhost for internal RPC calls.
# If it's been used by other services, ccnet and seafile would not be able to run.
# If you want to run seafile client and server on the same machine, change this port for the client.
PORT=13419
Note: You should restart seafile so that your changes take effect.
cd seafile-server
./seafile.sh restart
Seafile.conf settings
[quota]
# default user quota in GB, integer only
default = 2
This setting applies to all users. If you want to set quota for a specific user, you may log in to seahub website as
administrator, then set it in "System Admin" page.
Default history length limit (seafile.conf)
If you don't want to keep all file revision history, you may set a default history length limit for all libraries.
[history]
keep_days = days of history to keep
Seafile fileserver configuration (seafile.conf)
The configuration of seafile fileserver is in the [fileserver] section of the file seafile-data/seafile.conf
[fileserver]
# tcp port for fileserver
port = 8082
[fileserver]
# Set maximum upload file size to 200M.
max_upload_size=200
Note: You need to restart seafile and seahub so that your changes take effect.
./seahub.sh restart
./seafile.sh restart
Seahub Settings
EMAIL_USE_TLS = False
EMAIL_HOST = 'smtp.domain.com' # smpt server
EMAIL_HOST_USER = '[email protected]' # username and domain
EMAIL_HOST_PASSWORD = 'password' # password
EMAIL_PORT = '25'
DEFAULT_FROM_EMAIL = EMAIL_HOST_USER
SERVER_EMAIL = EMAIL_HOST_USER
EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = '[email protected]'
EMAIL_HOST_PASSWORD = 'password'
EMAIL_PORT = 587
DEFAULT_FROM_EMAIL = EMAIL_HOST_USER
SERVER_EMAIL = EMAIL_HOST_USER
Note: If your Email service still can not work, you may checkout the log file logs/seahub.log to see what may cause the
problem. For complete email notification list, please refer to Email notification list.
Note2: If you want to use the Email service without authentication leaf EMAIL_HOST_USER and EMAIL_HOST_PASSWORD blank
( '' ). (But notice that the emails then will be sent without a From: address.)
Memcached
Seahub caches items(avatars, profiles, etc) on file system by default(/tmp/seahub_cache/). You can replace with
Memcached. After install python-memcache, add the following lines to seahub_settings.py.
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
'LOCATION': '127.0.0.1:11211',
}
}
Other options
You may change seahub website's settings by adding variables in seahub_settings.py .
# Set this to seahub website's URL. This URL is contained in email notifications.
SITE_BASE = 'http://www.example.com/'
# If you don't want to run seahub website on your site's root path, set this option to your preferred path.
# e.g. setting it to '/seahub/' would run seahub on http://example.com/seahub/.
SITE_ROOT = '/'
# Whether to use pdf.js to view pdf files online. Default is `True`, you can turn it off.
# NOTE: since version 1.4.
USE_PDFJS = True
# Whether to send email when a system admin adding a new member. Default is `True`.
# NOTE: since version 1.4.
SEND_EMAIL_ON_ADDING_SYSTEM_MEMBER = True
# Whether to send email when a system admin resetting a user's password. Default is `True`.
# NOTE: since version 1.4.
SEND_EMAIL_ON_RESETTING_USER_PASSWD = True
# Whether a user's session cookie expires when the Web browser is closed.
SESSION_EXPIRE_AT_BROWSER_CLOSE = False
# Using server side crypto by default, otherwise, let user choose crypto method.
# This option only controls files upload/download via web browser.
# Syncing via desktop clients is always encrypted on the clients side.
FORCE_SERVER_CRYPTO = True
Note:
Customize Logo
LOGO_PATH = 'custom/mylogo.png'
LOGO_URL = 'http://your-seafile.com'
BRANDING_CSS = 'custom/custom.css'
Customize footer and other Seahub Pages
Note: Since version 2.1.
Customize footer
EMAIL_USE_TLS = False
EMAIL_HOST = 'smtp.domain.com' # smpt server
EMAIL_HOST_USER = '[email protected]' # username and domain
EMAIL_HOST_PASSWORD = 'password' # password
EMAIL_PORT = '25'
DEFAULT_FROM_EMAIL = EMAIL_HOST_USER
SERVER_EMAIL = EMAIL_HOST_USER
EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = '[email protected]'
EMAIL_HOST_PASSWORD = 'password'
EMAIL_PORT = 587
DEFAULT_FROM_EMAIL = EMAIL_HOST_USER
SERVER_EMAIL = EMAIL_HOST_USER
Note: If your Email service still can not work, you may checkout the log file logs/seahub.log to see what may cause the
problem. For complete email notification list, please refer to Email notification list.
Note2: If you want to use the Email service without authentication leaf EMAIL_HOST_USER and EMAIL_HOST_PASSWORD blank
( '' ). (But notice that the emails then will be sent without a From: address.)
Customize Email Notifications
Note: Subject line may vary between different releases, this is based on Release 2.0.1. Restart Seahub so that your
changes take effect.
User reset his/her password
Subject
seahub/seahub/auth/forms.py line:103
Body
seahub/seahub/templates/registration/password_reset_email.html
System admin add new member
Subject
seahub/seahub/views/sysadmin.py line:424
Body
seahub/seahub/templates/sysadmin/user_add_email.html
System admin reset user password
Subject
seahub/seahub/views/sysadmin.py line:368
Body
seahub/seahub/templates/sysadmin/user_reset_email.html
User send file/folder share link
Subject
seahub/seahub/share/views.py line:668
Body
seahub/seahub/templates/shared_link_email.html
Customize user management
# Whether to send email when a system admin adding a new member. Default is `True`.
# NOTE: since version 1.4.
SEND_EMAIL_ON_ADDING_SYSTEM_MEMBER = True
# Whether a user's session cookie expires when the Web browser is closed.
SESSION_EXPIRE_AT_BROWSER_CLOSE = False
Administration
As the system admin, you can enter the admin panel by click the tools button at the top-left, beside the avatar:
After clicking the button, you will get into the admin panel:
Account management
Account management
Logs
Seafile FSCK
Seafile GC
Account Management
User Management
When you setup seahub website, you should have setup a admin account. After you logged in a admin, you may
add/delete users and file libraries.
In a private server, the default settings doesn't support users to reset their password by email. If you want to enable this,
you have first to set up notification email.
You may run reset-admin.sh script under seafile-server directory. This script would help you reset the admin account and
password.
Logs
Log files of seafile server:
If you setup seafile server according to our manual, you should have a directory layout like:
Seafile also stores some important metadata data in a few databases. The names and locations of these databases
depends on which database software you use.
For SQLite, the database files are also under the 'haiwen' directory. The locations are:
For MySQL, the databases are created by the administrator, so the names can be different from one deployment to
another. There are 3 databases:
We assume your seafile data directory is in /data/haiwen . And you want to backup to /backup directory. The /backup can
be an NFS or Windows share mount exported by another machine, or just an external disk. You can create a layout
similar to the following in /backup directory:
/backup
---- databases/ contains database backup files
---- data/ contains backups of the data directory
Backing up Databases
It's recommended to backup the database to a separate file each time. Don't overwrite older database backups for at least
a week.
MySQL
Assume your database names are ccnet-db , seafile-db and seahub-db . mysqldump automatically locks the tables so you
don't need to stop Seafile server when backing up MySQL databases. Since the database tables are usually very small, it
won't take long to dump.
SQLite
You need to stop Seafile server first before backing up SQLite database.
The data files are all stored in the /data/haiwen directory, so just back up the whole directory. You can directly copy the
whole directory to the backup destination, or you can use rsync to do incremental backup.
If you have a lot of data, copying the whole data directory would take long. You can use rsync to do incremental backup.
Important: The ID in ccnet/ccnet.conf must be consistent with the SHA1 value of ccnet/mykey.peer . So do not forget to copy
ccnet/mykey.peer .
Restore from backup
Now supposed your primary seafile server is broken, you're switching to a new machine. Using the backup data to
restore your Seafile instance:
1. Copy /backup/data/haiwen to the new machine. Let's assume the seafile deployment location new machine is also
/data/haiwen .
2. Restore the database.
3. Run seaf-fsck tool to check data integrity on the new machine. See seaf-fsck documentation.
Now with the latest valid database backup files at hand, you can restore them.
MySQL
SQLite
cd /data/haiwen
mv ccnet/PeerMgr/usermgr.db ccnet/PeerMgr/usermgr.db.old
mv ccnet/GroupMgr/groupmgr.db ccnet/GroupMgr/groupmgr.db.old
mv seafile-data/seafile.db seafile-data/seafile.db.old
mv seahub.db seahub.db.old
sqlite3 ccnet/PeerMgr/usermgr.db < usermgr.db.bak.xxxx
sqlite3 ccnet/GroupMgr/groupmgr.db < groupmgr.db.bak.xxxx
sqlite3 seafile-data/seafile.db < seafile.db.bak.xxxx
sqlite3 seahub.db < seahub.db.bak.xxxx
Seafile FSCK
On the server side, Seafile stores the files in the libraries in an internal format. Seafile has its own representation of
directories and files (similar to Git).
With default installation, these internal objects are stored in the server's file system directly (such as Ext4, NTFS). But
most file systems don't assure the integrity of file contents after a hard shutdown or system crash. So if new Seafile
internal objects are being written when the system crashes, they can be corrupt after the system reboots. This will make
part of the corresponding library not accessible.
Note: If you store the seafile-data directory in a battery-backed NAS (like EMC or NetApp), or use S3 backend available in
the Pro edition, the internal objects won't be corrupt.
Starting from version 2.0, Seafile server comes with a seaf-fsck tool to help you recover from this corruption (similar to git-
fsck tool). This tool recovers any corrupted library back to its last consistent and usable state.
Supposed you follow the standard installation and directory layout, and your seafile installation directory is /data/haiwen ,
you should run the command as
cd /data/haiwen/seafile-server-{version}/seafile
export LD_LIBRARY_PATH=./lib:${LD_LIBRARY_PATH}
./bin/seaf-fsck -c ../../ccnet -d ../../seafile-data
If you know exactly which library is corrupt, you can also specify the library's id in the command line. A library's id can be
obtained by navigating into the library on seahub. In the browser's address bar, you should see something like:
https://seafile.example.com/repo/601c4f2f-5209-47a0-b939-1f8c7fae9ff2 . 601c4f2f-5209-47a0-b939-1f8c7fae9ff2 is the library id.
After the recovery, a few latest changes to the files may be lost, but you can access the full library now. Also note that
some clients synced with the library can fail to sync. If this happens, you can unsync the library on the client and resync
with the library's folder.
Seafile GC
Seafile uses storage de-duplication technology to reduce storage usage. Simply put, there would be two implications:
The net result is that the underlying data blocks will not be removed immediately after you delete a file library. As a result,
the number of unused data blocks will increase on Seafile server.
To release the storage space occupied by unused blocks, you have to run a "garbage collection" program to clean up
unused blocks on your server.
Before running GC, you must shutdown the seafile program on your server. This is because new blocks written into
Seafile while GC is running may be mistakenly deleted by the GC program.
Run GC in version 3.1.2 and later
To run GC program
./seaf-gc.sh run
After the GC program terminates, you may also check whether it mistakenly removed any useful data blocks:
./seaf-gc.sh verify
If you want to do sanity check before actually removing any data, you can use the --dry-run option
./seaf-gc.sh dry-run
It will show you the total block number vs. the number of blocks to be removed.
If the metadata of some libraries are damaged on the server, the GC program would stop proceeding because it can't tell
whether a block is used by some damaged libraries or not. If you don't want to keep the data of the damaged library, you
can run GC with force option
./seaf-gc.sh force
This will mask the blocks of the damaged libraries as unused and delete them.
Run GC before version 3.1.2
To run GC program
cd seafile-server-{version}/seafile
export LD_LIBRARY_PATH=./lib:${LD_LIBRARY_PATH}
./bin/seafserv-gc -c ../../ccnet -d ../../seafile-data
After the GC program terminates, you may also check whether it mistakenly removed any useful data blocks:
If you want to do sanity check before actually removing any data, you can use the --dry-run option
It will show you the total block number vs. the number of blocks to be removed.
If the metadata of some libraries are damaged on the server, the GC program would stop proceeding because it can't tell
whether a block is used by some damaged libraries or not. If you don't want to keep the data of the damaged library, you
can run GC with --ignore-errors or -i option
This will mask the blocks of the damaged libraries as unused and delete them.
WebDAV and FUSE extensions
Seafile WebDAV and FUSE extensions make it easy for Seafile to work with third party applications. For example, you
can use Documents App in iOS to access files in Seafile via WebDAV interface.
WebDAV extension
Seafile WebDAV Server(SeafDAV) is added in seafile server 2.1.0.
[WEBDAV]
port = 8080
Every time the configuration is modified, you need to restart seafile server to make it take effect.
./seafile.sh restart
Your WebDAV client would visit the Seafile WebDAV server at http://example.com:8080
[WEBDAV]
enabled = true
port = 8080
fastcgi = false
share_name = /
Your WebDAV client would visit the Seafile WebDAV server at http://example.com/seafdav
[WEBDAV]
enabled = true
port = 8080
fastcgi = true
share_name = /seafdav
In the above config, the value of '''share_name''' is changed to '''/seafdav''', which is the address suffix you assign to
seafdav server.
access_log /var/log/nginx/seafdav.access.log;
error_log /var/log/nginx/seafdav.error.log;
}
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;
client_max_body_size 0;
access_log /var/log/nginx/seafdav.access.log;
error_log /var/log/nginx/seafdav.error.log;
}
Apache
First edit apache2.conf file, add this line to the end of the file (or add it to httpd.conf depending on your Linux distro):
Note, /var/www/seafdav.fcgi is just a placeholder, you don't need to actually have this file in your system.
Based on your apache configuration when you [[Deploy Seafile with apache|deployed seafile with Apache]], add seafdav
related config:
ServerName www.myseafile.com
DocumentRoot /var/www
Alias /media /home/user/haiwen/seafile-server/seahub/media
RewriteEngine On
#
# seafile fileserver
#
ProxyPass /seafhttp http://127.0.0.1:8082
ProxyPassReverse /seafhttp http://127.0.0.1:8082
RewriteRule ^/seafhttp - [QSA,L]
#
# seafile webdav
#
RewriteCond %{HTTP:Authorization} (.+)
RewriteRule ^(/seafdav.*)$ /seafdav.fcgi$1 [QSA,L,e=HTTP_AUTHORIZATION:%1]
RewriteRule ^(/seafdav.*)$ /seafdav.fcgi$1 [QSA,L]
#
# seahub
#
RewriteRule ^/(media.*)$ /$1 [QSA,L,PT]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /seahub.fcgi$1 [QSA,L,E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
Based on your apache configuration when you Enable Https on Seafile web with Apache, add seafdav related config:
ServerName www.myseafile.com
DocumentRoot /var/www
Alias /media /home/user/haiwen/seafile-server/seahub/media
SSLEngine On
SSLCertificateFile /etc/ssl/cacert.pem
SSLCertificateKeyFile /etc/ssl/privkey.pem
RewriteEngine On
#
# seafile fileserver
#
ProxyPass /seafhttp http://127.0.0.1:8082
ProxyPassReverse /seafhttp http://127.0.0.1:8082
RewriteRule ^/seafhttp - [QSA,L]
#
# seafile webdav
#
RewriteCond %{HTTP:Authorization} (.+)
RewriteRule ^(/seafdav.*)$ /seafdav.fcgi$1 [QSA,L,e=HTTP_AUTHORIZATION:%1]
RewriteRule ^(/seafdav.*)$ /seafdav.fcgi$1 [QSA,L]
#
# seahub
#
RewriteRule ^/(media.*)$ /$1 [QSA,L,PT]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /seahub.fcgi$1 [QSA,L,E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
Notes on Clients
Windows
On Windows it is recommended to use a webdav client software such as Cyberduck or BitKinex. The implementation of
webdav support in Windows explorer is not very usable since:
Windows explorer requires to use HTTP digest authentication. But Seafile can't support this because it doesn't store plain text passwords on the server
The conclusion is if you have a valid ssl certificate, you should be able to access seafdav from Windows explorer.
Otherwise you should use a client software. It's also reported that Windows XP doesn't support HTTPS webdav.
Linux
On Linux you have more choices. You can use file manager such as Nautilus to connect to webdav server. Or you can
use davfs2 from the command line.
To use davfs2
The -o option sets the owner of the mounted directory to so that it's writable for non-root users.
It's recommended to disable LOCK operation for davfs2. You have to edit /etc/davfs2/davfs2.conf
use_locks 0
Mac OS X
Finder's support for WebDAV is also not very stable and slow. So it is recommended to use a webdav client software such
as Cyberduck.
Frequently Asked Questions
By default, seafdav is disabled. Check whether you have enabled = true in seafdav.conf . If not, modify it and restart seafile
server.
If you deploy SeafDAV behind Nginx/Apache, make sure to change the value of share_name as the sample configuration
above. Restart your seafile server and try again.
FUSE extension
Files in the seafile system are split to blocks, which means what are stored on your seafile server are not complete files,
but blocks. This design faciliates effective data deduplication.
However, administrators sometimes want to access the files directly on the server. You can use seaf-fuse to do this.
Seaf-fuse is an implementation of the FUSE virtual filesystem. In a word, it mounts all the seafile files to a folder (which is
called the '''mount point'''), so that you can access all the files managed by seafile server, just as you access a normal
folder on your server.
Note:
mkdir -p /data/seafile-fuse
Note: Before start seaf-fuse, you should have started seafile server with ./seafile.sh start .
Stop seaf-fuse
./seaf-fuse.sh stop
$ ls -lhp /data/seafile-fuse
The top level folder contains many subfolders, each of which corresponds to a user
The time stamp of files and folders is not preserved.
From the above list you can see, under the folder of a user there are subfolders, each of which represents a library of that
user, and has a name of this format: '''{library_id}-{library-name}'''.
$ ls -lhp /data/seafile-fuse/[email protected]/5403ac56-5552-4e31-a4f1-1de4eb889a5f_Photos/
If you get an error message saying "Permission denied" when running ./seaf-fuse.sh start , most likely you are not in the
"fuse group". You should:
Security features
Security features
Access log and auditing
Access log and auditing
Access log and auditing
Seafile offers administrators following tools to monitor the system:
date, operation type, user, ip, web agent, library_id, library_name, file path.
Exmaple:
2014-09-15 14:11:42,679 - file-download-web [email protected] 127.0.0.1 "Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.
Client
Linux
Max OS X
Server
Preparation
The following list is what you need to install on your development machine. You should install all of them before you
build seafile.
Package names are according to Ubuntu 12.04. For other Linux distros, please find their corresponding names yourself.
autoconf/automake/libtool
libevent-dev ( 2.0 or later )
libcurl4-openssl-dev (1.0.0 or later)
libgtk2.0-dev ( 2.24 or later)
uuid-dev
intltool (0.40 or later)
libsqlite3-dev (3.7 or later)
valac (only needed if you build from git repo)
libjansson-dev
libqt4-dev
valac
cmake
libfuse-dev (for seafile >= 2.1)
python-simplejson (for seaf-cli)
sudo apt-get install autoconf automake libtool libevent-dev libcurl4-openssl-dev libgtk2.0-dev uuid-dev intltool libsqlite3-dev valac libjansson-dev libqt4
For a fresh Fedora 20 installation, the following will install all dependencies via YUM:
$ sudo yum install wget gcc libevent-devel openssl-devel gtk2-devel libuuid-devel sqlite-devel jansson-devel intltool cmake qt-devel fuse-devel libtool v
Building
For example, if the latest released seafile client is 3.0.2, then just use the v3.0.2 tags of the four projects. You should get
four tarballs:
libsearpc-v3.0-latest.tar.gz
ccnet-3.0.2.tar.gz
seafile-3.0.2.tar.gz
seafile-client-3.0.2.tar.gz
export version=3.0.2
alias wget='wget --content-disposition -nc'
wget https://github.com/haiwen/libsearpc/archive/v3.0-latest.tar.gz
wget https://github.com/haiwen/ccnet/archive/v${version}.tar.gz
wget https://github.com/haiwen/seafile/archive/v${version}.tar.gz
wget https://github.com/haiwen/seafile-client/archive/v${version}.tar.gz
tar xf libsearpc-v3.0-latest.tar.gz
tar xf ccnet-${version}.tar.gz
tar xf seafile-${version}.tar.gz
tar xf seafile-client-${version}.tar.gz
To build Seafile client, you need first build libsearpc and ccnet, seafile.
set paths
export PREFIX=/usr
export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PKG_CONFIG_PATH"
export PATH="$PREFIX/bin:$PATH"
libsearpc
cd libsearpc-3.0-latest
./autogen.sh
./configure --prefix=$PREFIX
make
sudo make install
ccnet
cd ccnet-${version}
./autogen.sh
./configure --prefix=$PREFIX
make
sudo make install
seafile
cd seafile-${version}/
./autogen.sh
./configure --prefix=$PREFIX --disable-gui
make
sudo make install
seafile-client
cd seafile-client-${version}
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PREFIX .
make
sudo make install
custom prefix
when installing to a custom $PREFIX , i.e. /opt , you may need a script to set the path variables correctly
cat >$PREFIX/bin/seafile-applet.sh <<END
#!/bin/bash
export LD_LIBRARY_PATH="$PREFIX/lib:$LD_LIBRARY_PATH"
export PATH="$PREFIX/bin:$PATH"
exec seafile-applet $@
END
cat >$PREFIX/bin/seaf-cli.sh <<END
export LD_LIBRARY_PATH="$PREFIX/lib:$LD_LIBRARY_PATH"
export PATH="$PREFIX/bin:$PATH"
export PYTHONPATH=$PREFIX/lib/python2.7/site-packages
exec seaf-cli $@
END
chmod +x $PREFIX/bin/seafile-applet.sh $PREFIX/bin/seaf-cli.sh
Preparation
The following list is what you need to install on your development machine. You should install all of them before you
build seafile.
Package names are according to FreeBSD Ports. You might install your ports manually or via pkgng .
devel/autoconf
devel/automake
textproc/intltool
textproc/gsed
devel/libtool
devel/libevent2
ftp/curl
devel/glib20
misc/ossp-uuid
databases/sqlite3
devel/jansson
lang/vala
devel/cmake
archivers/libarchive
devel/py-simplejson (removed in furture release)
GUI
devel/qt4
Building
For example, if the latest released seafile client is 3.1.0, then just use the v3.1.0 tags of the four projects. You should get
four tarballs:
libsearpc-v3.0-latest.tar.gz
ccnet-3.1.0.tar.gz
seafile-3.1.0.tar.gz
seafile-client-3.1.0.tar.gz
export version=3.1.0
alias wget='wget --content-disposition -nc'
wget https://github.com/haiwen/libsearpc/archive/v3.0-latest.tar.gz
wget https://github.com/haiwen/ccnet/archive/v${version}.tar.gz
wget https://github.com/haiwen/seafile/archive/v${version}.tar.gz
wget https://github.com/haiwen/seafile-client/archive/v${version}.tar.gz
tar xf libsearpc-v3.0-latest.tar.gz
tar xf ccnet-${version}.tar.gz
tar xf seafile-${version}.tar.gz
tar xf seafile-client-${version}.tar.gz
To build Seafile client, you need first build libsearpc and ccnet, seafile.
set paths
libsearpc
cd libsearpc-${version}
./autogen.sh
./configure --prefix=$PREFIX
make
sudo make install
ccnet
seafile
cd seafile-${version}/
./autogen.sh
./configure --prefix=$PREFIX
make
sudo make install
seafile-client
cd seafile-client-${version}
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PREFIX .
make
sudo make install
custom prefix
when installing to a custom $PREFIX , i.e. /opt , you may need a script to set the path variables correctly
If you face any installation issue, please report it with your homebrew logs
Homebrew Troubleshooting
If it is an issue while using homebrewed seafile, please report it with your seafile logs
Seafile FAQ
Setup macports environment
1. Install xcode
4. Install python
export PKG_CONFIG_PATH=/opt/local/lib/pkgconfig:/usr/local/lib/pkgconfig
export LIBTOOL=glibtool
export LBITOOLIZE=glibtoolize
export SED=gsed
export LDFLAGS="-L/opt/local/lib -luuid -L/usr/local/lib -Wl,-headerpad_max_install_names"
Compiling libsearpc
Download libsearpc, then:
./autogen.sh
./configure
make
sudo make install
Compiling ccnet
Download ccnet, then:
./autogen.sh
CFLAGS="-I/opt/local/include" LDFLAGS="-L/opt/local/lib -luuid -L/usr/local/lib -Wl,-headerpad_max_install_names" ./configure
make
sudo make install
Compiling seafile
1. Download seafile
2. Compile
./autogen.sh
SED=sed CFLAGS="-I/opt/local/include" LDFLAGS="-L/opt/local/lib -luuid -L/usr/local/lib -Wl,-headerpad_max_install_names" ./configure
make
sudo make install
Compiling seafile-client and packaging it
1. prepare for building:
./genapp.sh xcode
2. Compile seafile.app:
./genapp.sh build
If you are told build failed, you might try to use HEAD version of seafile-client, or any tag which ends up with "mac"
3. Package seafile.app:
./genapp.sh otool
./genapp.sh package
./genapp.sh dmg
This will copy ccnet, seaf-daemon and other libraries to seafile-client, and use install_name_tool to modify the library
paths in ccnet, seaf-daemon. After compiling, it will copy seafile.app to ${top_dir}/../seafile-${VERSION} . You can also
compiling seafile.app in xcode.
Preparation
The following list is all the libraries you need to install on your machine. '''You should install all of them before you build
seafile'''.
Package names are according to Ubuntu 12.04. For other Linux distros, please find their corresponding names yourself.
libzdb [http://www.tildeslash.com/libzdb/dist/libzdb-2.12.tar.gz]
libevhtp [https://github.com/ellzey/libevhtp/archive/1.1.6.zip]
libzdb relies on two packages: re2c and flex . libevhtp can be build by cmake .; make; sudo make install . libevhtp's version
should be 1.1.6 or 1.1.7.
'''Seahub''' is the web front end of Seafile. It's written in the [http://djangoproject.com django] framework. Seahub requires
Python 2.6(2.7) installed on your server, and it needs the following python libraries:
The module '''argparser''' is required by the seafile-admin script which you'll see later. If you use Python 2.7, '''argparser''' is
distributed with python's standard library, so you don't need to install it. But if you use Python 2.6, you should install it
manually.
Before continue, make sure you have all the above libraries available in your system.
In the following sections, you'll be guided to build and setup the seafile server step by step. Seafile server is consisted of
several components. In order for them to function correctly, you must:
First create the top level directory. In the following sections, we'll use "/data/haiwen" as the top level directory.
mkdir /data/haiwen/
cd /data/haiwen/
mkdir seafile-server
cd seafile-server
haiwen/
└── seafile-server
[https://github.com/haiwen/libsearpc/tags]
[https://github.com/haiwen/ccnet/tags]
[https://github.com/haiwen/seafile/tags]
[https://github.com/haiwen/seahub/tags]
For example, if the latest released seafile client is 2.0.3, then just use the '''v2.0.3-server''' tags of the four projects. You
should get four tarballs:
libsearpc-2.0.3-server.tar.gz
ccnet-2.0.3-server.tar.gz
seafile-2.0.3-server.tar.gz
seahub-2.0.3-server.tar.gz
cd haiwen/seafile-server
mkdir src
cd src
tar xf /path/to/libsearpc-2.0.3-server.tar.gz
tar xf /path/to/ccnet-2.0.3-server.tar.gz
tar xf /path/to/seafile-2.0.3-server.tar.gz
cd haiwen/seafile-server
tar xf /path/to/seahub-2.0.3-server.tar.gz
mv seahub-2.0.3-server seahub
haiwen/
└── seafile-server
└── seahub
└── src
├── libsearpc-2.0.3-server
├── ccnet-2.0.3-server
├── seafile-2.0.3-server
├── ... (other files)
Building
To build seafile server, you need first build '''libsearpc''' and '''ccnet'''.
libsearpc
cd libsearpc-${version}
./autogen.sh
./configure
make
make install
ccnet
cd ccnet-${version}
./autogen.sh
./configure --disable-client --enable-server # `export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig` if libsearpc is not found
make
make install
seafile
cd seafile-${version}
./autogen.sh
./configure --disable-client --enable-server
make
make install
Deploy Seafile Server
[[images/server-arch.png]]
ensure seafile is already installed and all the python libraries seahub needs are installed.
create the ccnet configuration with the '''ccnet-init''' program
create the seafile configuration with '''seaf-server-init''' program
run Django '''syncdb''' command for seahub
create an admin account for the seafile server
seafile-admin should have been installed to system path after you have built and installed Seafile from source.
optional arguments:
-h, --help show this help message and exit
subcommands:
{setup,start,stop,reset-admin}
setup setup the seafile server
start start the seafile server
stop stop the seafile server
reset-admin reset seafile admin account
Go to the top level directory(in this guide it's '''/data/haiwen/'''), and run '''seafile-admin setup''' to create all the
configuration:
cd /data/haiwen
export PYTHONPATH=/data/haiwen/seafile-server/seahub/thirdpart
seafile-admin setup
The script would ask you a series of questions, and create all the configuration for you.
ip or The ip address or domain name of Make sure to use the right ip or domain, or the
domain the server client would have trouble connecting it
seafile
fileserver tcp port used by seafile fileserver 8082
port
admin
password of the admin account
password
haiwen/
└── ccnet # ccnet config directory
└── ccnet.conf # ccnet config file
└── seafile-data # seafile configuration and data
└── seafile.conf # seafile config file
└── seahub-data/ # seahub data
└── seahub.db # seahub sqlite3 database
└── seahub_settings.py # custom settings for seahub
└── seafile-server
└── seahub/
└── seafile-{VERSION} # seafile source code
After configuration successfully created, run '''seafile-admin start''' in the top directory to start the all components of
Seafile. ( '''You should always run the seafile-admin script in the top directory''' ).
At this moment, all the components should be running and seahub can be visited at '''http://yourserver-ip-or-
domain:8000'''
'''Note''' You may want to deploy seahub with nginx or apache. In this case, follow the instructions on [[Deploy Seafile Web
With Nginx/Apache]].
cd /data/haiwen
seafile-admin stop
Get and latest source code and build libsearpc/ccnet/seafile, just as what you do in a fresh setup.
Run the upgrade script. The upgrade script mainly updates database used by seafile for you. For example, create a
new database table that is used in the latest seafile server but not in the previous version.
cd haiwen/seafile-server
mv seahub/ seahub-old # move away the old seahub folder
tar xf /path/to/new/seahub-x.x.x-server.tar.gz
mv seahub-x.x.x-server seahub
Do the upgrade
The upgrade scripts is distributed in the scripts/upgrade subdir of seafile source code, we need to copy it to '''seafile-
server''' directory before run the scripts.
cd /data/haiwen/seafile-server
cp -rf seafile-{version}/scripts/upgrade .
Continuous upgrade means to upgrade from one version of seafile server to the next version. For example, upgrading
from 1.1.0 to 1.2.0 is a continuous upgrade.
'''Note:''' Minor upgrade, like upgrade from 1.3.0 to 1.3.1, is documented in a separate section below.
Say you are upgrading from 1.1.0 to 1.2.0, you should run the script '''upgrade_1.1_1.2.sh''' in seafile-server directory.
cd /data/haiwen/seafile-server
./upgrade/upgrade_1.1_1.2.sh
If you upgrade a few versions at once, e.g. from 1.1.0 to 1.3.0. The procedure is:
Minor upgrade Minor upgrade is like an upgrade from 1.3.0 to 1.3.1. For this type of upgrade, you only need to update the
avatar link:
cd /data/haiwen/seafile-server/seahub/media
cp -rf avatars/* ../../../seahub-data/avatars/
rm -rf avatars
ln -s ../../../seahub-data/avatars
Problems Report
If you encounter any problem when building/deploying Seafile, please leave us a message or
[https://github.com/haiwen/seafile/issues open an issue].
Setup Develop Environment
Preparation
Package names are according to Ubuntu 12.04. For other Linux distros, please find their corresponding names yourself.
libzdb
libevhtp
libzdb relies on two packages: re2c and flex . libevhtp can be build by cmake .; make; sudo make install . libevhtp's version
should be 1.1.6 or 1.1.7.
'''Seahub''' is the web front end of Seafile. It's written in the Django framework. Seahub requires Python 2.6(2.7) installed
on your server, and it needs the following python libraries:
Django1.5
Djblets
sqlite3
simplejson (python-simplejson)
PIL (aka. python imaging library, python-image) or Pillow
chardet
Download & Compile
Clone libsearpc, ccnet, seafile, seahub to ~/dev (or wherever you want).
cd ~/dev/libsearpc
./autogen.sh
./configure
make
make install
cd ~/dev/ccnet
./autogen.sh
./configure --disable-client --enable-server # `export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig` if libsearpc is not found
make
make install
cd ~/dev/seafile
./autogen.sh
./configure --disable-client --enable-server
make
make install
Run seafile
Run seafile with
cd ~/dev/seafile/tests/basic
./seafile.sh 2
cd ~/dev/seahub
Download django-1.5 to thirdpart. And create and modify setenv.sh from templates
cp setenv.sh.template setenv.sh
Create database
. setenv.sh
python manage.py syncdb
Start seahub
./run-seahub.sh.template
Code Standard
The source code of seafile is ISO/IEC 9899:1999 (E) (a.k.a. C99) compatible.
Indent
Inline
Const
We are using keyword const in the source.Please look into the code for detail.
Web API
Seafile Web API V2
API Basics
Status Code
Quick Start
Account
List Accounts
Check Account Info
Create Account
Update Account
Delete Account
Starred Files
List starred files
Star A File
Unstar A File
User Messages
List User Messages
Reply A User Message
Count Unseen Messages
Group
List Groups
Add A Group
Delete Group
Rename Group
Group Member
Add A Group Member
Delete A Group Member
Group Message
Get Group Messages
Get Group Message Detail
Send A Group Message
Reply A Group Message
Get Group Message Replies
Share
File Share Link
List File Share Links
Create File Share Link
Delete File Share Link
Shared Libraries
List Shared Libraries
List Be Shared Libraries
Share A Library
Unshare A Library
Shared Files
List Shared Files
Download Shared File
Get Shared File Detail
Delete Shared File
Download Private Shared File
Get Private Shared File Detail
Library
Library
Get Default Library
Create Default Library
List Libraries
Get Library Info
Get Library Owner
Get Library History
Create Library
Check/Create Sub Library
Delete Library
Decrypt Library
Create Public Library
Remove Public Library
Fetch library download info
List Virtual Libraries
Search Libraries
File
Download File
Get File Detail
Get File History
Download File From a Revision
Create File
Rename File
Move File
Copy File
Revert File
Delete File
Upload File
Get Upload Link
Upload File
Update file
Get Update Link
Update File
Directory
List Directory Entries
Create New Directory
Rename Directory
Delete Directory
Download Directory
Share Directory
Batch Delete
Get Avatar
Get User Avatar
Get Group Avatar
API Basics
All API calls must be authenticated with a valid Seafile API key.
The api key can be retrieved by the obtain auth api. See the Quick Start for details.
curl https://cloud.seafile.com/api2/ping/
"pong"
{"token": "24fd3c026886e3121b2ca630805ed425c272cb96"}
auth ping
"pong"
Account
List Accounts
GET https://cloud.seafile.com/api2/accounts/
Request parameters
start (default to 0)
limit (default to 100)
scope (default None, accepted values: 'LDAP' or 'DB')
If scope parameter is passed then accounts will be searched inside the specific scope, otherwise it will be used the old
approach: first LDAP and, if no account is found, DB.
Sample request
Sample response
[
{
"email": "[email protected]"
},
{
"email": "[email protected]"
}
]
Errors
GET https://cloud.seafile.com/api2/account/info/
Sample request
Sample response
{
"usage": 26038531,
"total": 104857600,
"email": "[email protected]"
}
Errors
403 Invalid token
Create Account
PUT https://cloud.seafile.com/api2/accounts/{email}/
Request parameters
password
is_staff (defaults to False)
is_active (defaults to True)
Sample request
curl -v -X PUT -d "password=123456" -H "Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd" -H 'Accept: application/json; indent=4' htt
Sample response
...
< HTTP/1.0 201 CREATED
< Location: https://cloud.seafile.com/api2/accounts/[email protected]/
...
"success"
Success
Response code 201(Created) is returned and the Location header provides shared link.
Errors
Update Account
PUT https://cloud.seafile.com/api2/accounts/{email}/
Request parameters
password
is_staff (defaults to False)
is_active (defaults to True)
Sample request
Sample response
...
< HTTP/1.0 200 OK
...
"success"
Success
Errors
Delete Account
DELETE https://cloud.seafile.com/api2/accounts/{email}/
Sample request
Sample response
"success"
Errors
GET https://cloud.seafile.com/api2/starredfiles/
Sample request
Sample response
[
{
"repo": "99b758e6-91ab-4265-b705-925367374cf0",
"mtime": 1355198150,
"org": -1,
"path": "/foo/bar.doc",
"dir": false,
"size": 0
},
{
"repo": "99b758e6-91ab-4265-b705-925367374cf0",
"mtime": 1353751237,
"org": -1,
"path": "/add_folder-blue.png",
"dir": false,
"size": 3170
}
]
Star A File
POST https://cloud.seafile.com/api2/starredfiles/
Request parameters
repo_id (post)
p (post)
Sample request
Sample response
...
< HTTP/1.0 201 CREATED
< Location: https://cloud.seafile.com/api2/starredfiles/
...
"success"
Success
Response code is 201(Created) and Location header provides url of starred file list.
Errors
400 repo_id or p is missing, or p is not valid file path(e.g. /foo/bar/).
Unstar A File
DELETE https://cloud.seafile.com/api2/starredfiles/
Request parameters
repo_id
p
Sample request
curl -X DELETE -v -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' -H 'Accept: application/json; charset=utf-8; indent=4' 'https://c
Sample response
...
< HTTP/1.0 200 OK
...
"success"
Success
Errors
GET https://cloud.seafile.com/api2/user/msgs/{id_or_email}/
Request parameters
id_or_email
Sample request
Sample response
{
"to_email": "[email protected]",
"next_page": -1,
"msgs": [
{
"attachments": [
{
"path": "/123.md",
"repo_id": "c7436518-5f46-4296-97db-2fcba4c8c8db"
}
],
"timestamp": 1398233096,
"from_email": "[email protected]",
"msgid": 3,
"msg": "another test msg",
"nickname": "user"
},
{
"attachments": [],
"timestamp": 1398233067,
"from_email": "[email protected]",
"msgid": 2,
"msg": "a test msg",
"nickname": "user"
}
]
}
Errors
POST https://cloud.seafile.com/api2/user/msgs/{id_or_email}/
Request parameters
id_or_email
message
Sample request
{
"msgid": 4
}
Errors
GET https://cloud.seafile.com/api2/unseen_messages/
Sample request
Sample response
{
"count": 1
}
Group
List Groups
GET https://cloud.seafile.com/api2/groups/
Sample request
Sample response
{
"replynum": 0,
"groups": [
{
"ctime": 1398134171327948,
"creator": "[email protected]",
"msgnum": 0,
"mtime": 1398231100,
"id": 1,
"name": "lian"
},
{
"ctime": 1398236081042441,
"creator": "[email protected]",
"msgnum": 0,
"mtime": 0,
"id": 2,
"name": "123"
}
]
}
Add A Group
PUT https://cloud.seafile.com/api2/groups/
Request parameters
group_name
Sample request
Sample response
Errors
Delete Group
DELETE https://cloud.seafile.com/api2/groups/{group_id}/
Request parameters
None
Sample request
Success
Errors
Rename Group
POST https://cloud.seafile.com/api2/groups/{group_id}/
Request parameters
Sample request
Success
Errors
Group Member
PUT https://cloud.seafile.com/api2/groups/{group_id}/members/
Request parameters
user_name
Sample request
curl -X PUT -d "[email protected]"-H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' "https://cloud.seafile.com/api2/g
Sample response
{"success": true}
Errors
DELETE https://cloud.seafile.com/api2/groups/{group_id}/members/
Request parameters
user_name
Sample request
Sample response
{"success": true}
Errors
Group Message
GET https://cloud.seafile.com/api2/group/msgs/{group_id}/
Request parameters
group_id
Sample request
Sample response
{
"next_page": -1,
"msgs": [
{
"reply_cnt": 0,
"timestamp": 1398230602,
"replies": [],
"from_email": "[email protected]",
"msgid": 1,
"msg": "test discuss",
"nickname": "user"
}
]
}
GET https://cloud.seafile.com/api2/group/{group_id}/msg/{msg_id}/
Request parameters
group_id
msg_id
Sample request
Sample response
{
"reply_cnt": 2,
"timestamp": 1398230602,
"replies": [
{
"msg": "this is another test",
"timestamp": 1398232319,
"nickname": "user",
"msgid": 1,
"from_email": "[email protected]"
},
{
"msg": "this is another test",
"timestamp": 1398232508,
"nickname": "user",
"msgid": 3,
"from_email": "[email protected]"
}
],
"from_email": "[email protected]",
"msgid": 1,
"msg": "test discuss",
"nickname": "user"
}
Errors
POST https://cloud.seafile.com/api2/group/msgs/{group_id}/
Request parameters
message
group_id
repo_id(optional)
path(optional)
Sample request
Sample response
{
"msgid": 3
}
POST https://cloud.seafile.com/api2/group/{group_id}/msg/{msg_id}
Request parameters
group_id
msg_id
message
Sample request
Sample response
{
"msgid": 3
}
Errors
GET https://cloud.seafile.com/api2/new_replies/
Sample request
Sample response
[
{
"reply_cnt": 1,
"timestamp": 1398231100,
"replies": [
{
"msg": "@user test reply",
"timestamp": 1398234493,
"nickname": "123",
"msgid": 5,
"from_email": "[email protected]"
}
],
"from_email": "[email protected]",
"att": {
"repo": "c7436518-5f46-4296-97db-2fcba4c8c8db",
"path": "/123.md",
"type": "file",
"src": "recommend"
},
"msgid": 3,
"msg": "this is another test",
"nickname": "user"
}
]
Share
GET https://cloud.seafile.com/api2/shared-links/
Sample request
Sample response
{"fileshares": [{"username": "[email protected]", "repo_id": "a582d3bc-bcf5-421e-9125-741fa56d18d4", "ctime": null, "s_type": "d", "token": "e4108274
PUT https://cloud.seafile.com/api2/repos/{repo-id}/file/shared-link/
Request parameters
repo-id
type
p (Path to the file)
Sample request
curl -v -X PUT -d "type=f&p=/foo.md" -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' -H 'Accept: application/json; indent=4' http
curl -v -X PUT -d "type=d&p=/123/" -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' -H 'Accept: application/json; indent=4' https
Sample response
...
< HTTP/1.0 201 CREATED
< Location: https://cloud.seafile.com/f/9b437a7e55/
...
Success
Response code 201(Created) is returned and the Location header provides shared link.
Errors
400 Path is missing
500 Internal server error
DELETE https://cloud.seafile.com/api2/shared-links/?t=0ae587a7d1
Request parameters
Sample request
Sample response
...
< HTTP/1.0 200 OK
...
Shared Libraries
GET https://cloud.seafile.com/api2/shared-repos/
Sample request
Sample response
[{"repo_id": "7d42522b-1f6f-465d-b9c9-879f8eed7c6c", "share_type": "personal", "permission": "rw", "encrypted": false, "user": "[email protected]", "la
GET https://cloud.seafile.com/api2/beshared-repos/
Sample request
Sample response
"[{"user": "[email protected]", "repo_id": "989e3952-9d6f-4427-ab16-4bf9b53212eb", "share_type": "personal", "permission": "rw", "encrypted": false, "
Share A Library
PUT https://cloud.seafile.com/api2/shared-repos/{repo-id}/
Request parameters
If share_type is 'personal' then 'user' or 'users' param are required, if share_type is 'group' then 'group_id' parameter is
required. If share_type is 'public' no other params is required.
'user' or 'users' parameters can be a comma separated list of emails, in this case the share will be done for more users at
the same time. If a problem is encountered during multiple users sharing then the sharing process is aborted.
Sample request
Sample response
"success"
Unshare A Library
DELETE https://cloud.seafile.com/api2/shared-repos/{repo-id}/
Request parameters
If share_type is 'personal' then 'user' param is required, if share_type is 'group' then 'group_id' parameter is required. If
share_type is 'public' no other params is required.
Sample request
Sample response
"success"
Shared Files
GET https://cloud.seafile.com/api2/shared-files/
Sample request
Sample response
{"priv_share_in": [{"s_type": "f", "repo_id": "989e3952-9d6f-4427-ab16-4bf9b53212eb", "permission": "r", "to_user": "[email protected]", "token": "94aa
GET https://cloud.seafile.com/api2/f/{token}/
Request parameters
Sample request
Sample response
"http://192.168.1.101:8082/files/89223601/lib.md"
Errors
GET https://cloud.seafile.com/api2/f/{token}/detail/
Request parameters
Sample request
Sample response
{"repo_id": "989e3952-9d6f-4427-ab16-4bf9b53212eb", "name": "lib.md", "mtime": 1398218747, "path": "/lib.md", "type": "file", "id": "000000000000000
Errors
DELETE https://cloud.seafile.com/api2/shared-files/?t=0ae587a7d1
Request parameters
Sample request
Sample response
...
< HTTP/1.0 200 OK
...
GET https://cloud.seafile.com/api2/s/f/{token}/
Request parameters
Sample request
Sample response
"http://192.168.1.101:8082/files/6960d5a4/lib.md"
Errors
GET https://cloud.seafile.com/api2/s/f/{token}/detail/
Request parameters
Sample request
{"repo_id": "989e3952-9d6f-4427-ab16-4bf9b53212eb", "name": "lib.md", "shared_by": "[email protected]", "mtime": 1398218747, "path": "/lib.md", "t
Errors
Library
GET https://cloud.seafile.com/api2/default-repo/
Sample request
Sample response
{
"repo_id": "691b3e24-d05e-43cd-a9f2-6f32bd6b800e",
"exists": true
}
POST https://cloud.seafile.com/api2/default-repo/
Sample request
Sample response
{
"repo_id": "691b3e24-d05e-43cd-a9f2-6f32bd6b800e",
"exists": true
}
List Libraries
GET https://cloud.seafile.com/api2/repos/
Sample request
Sample response
[
{
"permission": "rw",
"encrypted": false,
"mtime": 1400054900,
"owner": "[email protected]",
"id": "f158d1dd-cc19-412c-b143-2ac83f352290",
"size": 0,
"name": "foo",
"type": "repo",
"virtual": false,
"desc": "new library",
"root": "0000000000000000000000000000000000000000"
},
{
"permission": "rw",
"encrypted": false,
"mtime": 1400054802,
"owner": "[email protected]",
"id": "0536b11a-a5fd-4482-9314-728cb3472f54",
"size": 0,
"name": "foo",
"type": "repo",
"virtual": false,
"desc": "new library",
"root": "0000000000000000000000000000000000000000"
}
]
GET https://cloud.seafile.com/api2/repos/{repo-id}/
Request parameters
repo-id
Sample request
Sample response
{
"encrypted": false,
"password_need": null,
"mtime": null,
"owner": "self",
"id": "632ab8a8-ecf9-4435-93bf-f495d5bfe975",
"size": 1356155,
"name": "org",
"root": "b5227040de360dd22c5717f9563628fe5510cbce",
"desc": "org file",
"type": "repo"
}
GET https://cloud.seafile.com/api2/repos/{repo-id}/owner/
Request parameters
repo-id
Sample request
curl -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d9b477fd' -H 'Accept: application/json; indent=4' https://cloud.seafile.com/api2/repos/d
Sample response
{
"owner": "[email protected]"
}
Errors
GET https://cloud.seafile.com/api2/repos/{repo-id}/history/
Request parameters
repo-id
Sample request
Sample response
{"commits": [{"rev_file_size": 0, "rev_file_id": null, "ctime": 1398045167, "creator_name": "[email protected]", "creator": "00000000000000000
Create Library
POST https://cloud.seafile.com/api2/repos/
Request parameters
name
desc (defaults to "new repo")
passwd (needed by encrypt library)
Sample request
Sample response
{
"encrypted": "",
"enc_version": 0,
"repo_id": "f15811fd-5c19-412c-b143-2ac83f352290",
"magic": "",
"relay_id": "c5e41170db250ea497075e2911104faf0105b7fb",
"repo_version": 1,
"relay_addr": "cloud.seafile.com",
"token": "c1f3defe9ba408cd7964427ec276843e9d10c23b",
"relay_port": "10001",
"random_key": "",
"email": "[email protected]",
"repo_name": "foo"
}
Success
Response code 200 and newly created library information are returned.
Errors
check if a dir has a corresponding sub_repo, if it does not have, create one
GET https://cloud.seafile.com/api2/repos/{repo-id}/dir/sub_repo/?p=/\&name=sub_lib
Request parameters
repo-id
p
name
Sample request
Sample response
{"sub_repo_id": "c0a3283c-013c-4a7c-8f68-006f06fa6dec"}
Errors
Delete Library
DELETE https://cloud.seafile.com/api2/repos/{repo-id}/
Sample request
curl -v -X DELETE -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' -H 'Accept: application/json; indent=4' https://cloud.seafile.com
Sample response
"success"
Errors
Decrypt Library
POST https://cloud.seafile.com/api2/repos/{repo-id}/
Request parameters
password
Sample request
Sample response
"success"
Errors
POST https://cloud.seafile.com/api2/repos/{repo-id}/public/
Request parameters
repo-id
Sample request
Sample response
...
< HTTP/1.0 200 OK
...
Success
Errors
DELETE https://cloud.seafile.com/api2/repos/{repo-id}/public/
Request parameters
repo-id
Sample request
Sample response
...
< HTTP/1.0 200 OK
...
Success
Errors
GET https://cloud.seafile.com/api2/repos/{repo-id}/download-info/
Request parameters
repo-id
Sample request
Sample response
{
"applet_root": "https://localhost:13420",
"relay_addr": "localhost",
"token": "46acc4d9ca3d6a5c7102ef379f82ecc1edc629e1",
"repo_id": "dae8cecc-2359-4d33-aa42-01b7846c4b32",
"relay_port": "10002",
"encrypted": "",
"repo_name": "test",
"relay_id": "8e4b13b49ca79f35732d9f44a0804940d985627c",
"email": "[email protected]"
}
GET https://cloud.seafile.com/api2/virtual-repos/
Sample request
Sample response
{"virtual-repos":
[
{"virtual_perm": "rw", "store_id": null, "worktree_invalid": false, "encrypted": false, "origin_repo_name": "lian", "last_modify": 0, "no_local_history":
{"virtual_perm": "rw", "store_id": null, "worktree_invalid": false, "encrypted": false, "origin_repo_name": "lian", "last_modify": 0, "no_local_history":
]
}
Search Libraries
GET https://cloud.seafile.com/api2/search/
Sample request
Sample response
{
"has_more": false,
"total": 3,
"results": [
{
"repo_id": "691b3e24-d05e-43cd-a9f2-6f32bd6b800e",
"name": "api.md",
"oid": "8ea78453bb474359cd9d8e2c4c4d8d9cbdcef0a2",
"last_modified": 1398045167,
"fullpath": "/api.md",
"size": 18939
},
{
"repo_id": "c5509062-9bca-4933-a7e0-c6da1d5f82be",
"name": "home.md",
"oid": "dda57aaffa5179829e064c7d0c142f47a8a65d3b",
"last_modified": 1397096831,
"fullpath": "/home.md",
"size": 1954
},
{
"repo_id": "c5509062-9bca-4933-a7e0-c6da1d5f82be",
"name": "\u5e38\u89c1\u5b89\u88c5\u95ee\u9898.md",
"oid": "8573f982eeb478b932a55ec13218f4f90a7c5a27",
"last_modified": 1397188959,
"fullpath": "/\u5e38\u89c1\u5b89\u88c5\u95ee\u9898.md",
"size": 1050
}
]
}
Errors
File
Download File
GET https://cloud.seafile.com/api2/repos/{repo-id}/file/?p=/foo
Request parameters
repo-id
p
Sample request
Sample response
"https://cloud.seafile.com:8082/files/adee6094/foo.c"
Errors
repo-id
p
Sample request
Sample response
{
"id": "013d3d38fed38b3e8e26b21bb3463eab6831194f",
"mtime": 1398148877,
"type": "file",
"name": "foo.py",
"size": 22
}
Errors
GET https://cloud.seafile.com/api2/repos/{repo-id}/file/history/?p=/foo.c
Request parameters
repo-id
p
Sample request
Sample response
{
"commits":
[
{
"rev_file_size": 0,
"repo_id": "a582d3bc-bcf5-421e-9125-741fa56d18d4",
"ctime": 1398149763,
"creator_name": "[email protected]",
"creator": "0000000000000000000000000000000000000000",
"root_id": "b64d413d9894c9206beac3faf9c2a0d75b4a8ebf",
"rev_renamed_old_path": null,
"parent_id": "8e546762e1657ab22dad83e9cb1e5ea31a767c9a",
"new_merge": false,
"version": 1,
"conflict": false,
"desc": "Added \"foo.c\"",
"id": "9464f7499bfa7363d563282361339eaf96a93318",
"rev_file_id": "0000000000000000000000000000000000000000",
"second_parent_id": null
},
{
"rev_file_size": 0,
"repo_id": "a582d3bc-bcf5-421e-9125-741fa56d18d4",
"ctime": 1398146059,
"creator_name": "[email protected]",
"creator": "0000000000000000000000000000000000000000",
"root_id": "572413414257c76039897e00aeb35f819471206b",
"rev_renamed_old_path": null,
"parent_id": "f977bdb0ebb205645c3b42216c2817e511c3f68f",
"new_merge": false,
"version": 1,
"conflict": false,
"desc": "Added \"foo.c\"",
"id": "a1ec20709675f4dc8db825cdbca296be245d189b",
"rev_file_id": "0000000000000000000000000000000000000000",
"second_parent_id": null
}
]
}
Errors
GET https://cloud.seafile.com/api2/repos/{repo-id}/file/revision/?
p=/foo.c&commit_id=a1ec20709675f4dc8db825cdbca296be245d189b
Request parameters
repo-id
p
commit_id
Sample request
Sample response
"https://cloud.seafile.com:8082/files/adee6094/foo.c"
Errors
400 Path is missing
404 Revision not found
Create File
POST https://cloud.seafile.com/api2/repos/{repo-id}/file/?p=/foo.c
Request parameters
repo-id
p
operation
Sample request
Sample response
...
< HTTP/1.1 201 CREATED
...
"success"
Success
Errors
Rename File
POST https://cloud.seafile.com/api2/repos/{repo-id}/file/?p=/foo.c
Request parameters
repo-id
p
operation
newname
Sample request
Sample response
...
< HTTP/1.1 301 MOVED PERMANENTLY
...
"success"
Success
Errors
400 BAD REQUEST, Path is missing or invalid(e.g. p=/) or newname is missing(newname too long)
403 FORBIDDEN, You do not have permission to rename file
404 NOT FOUND, repo not found
409 CONFLICT, the newname is the same to the old
520 OPERATION FAILED, fail to rename file
Move File
POST https://cloud.seafile.com/api2/repos/{repo-id}/file/?p=/foo.c
Request parameters
repo-id
p
operation
dst_repo
dst_dir
Sample request
Sample response
...
< HTTP/1.1 301 MOVED PERMANENTLY
...
"success"
Success
Errors
Copy File
POST https://cloud.seafile.com/api2/repos/{repo_id}/fileops/copy/
Request parameters
file_names: list of file/folder names to copy. Multiple file/folder names can be seperated by : .
dst_repo: the destination repo id
dst_dir: the destination folder in dst_repo
Sample request
Sample response
"success"
Errors
Revert File
PUT https://cloud.seafile.com/api2/repos/{repo_id}/file/revert/
Request parameters
repo_id
p
commit_id
Sample request
Sample response
...
< HTTP/1.0 200 OK
...
{"ret": 0}
Success
Errors
DELETE https://cloud.seafile.com/api2/repos/{repo-id}/file/?p=/foo
Request parameters
repo-id
p
Sample request
curl -X DELETE -v -H 'Authorization: Token f2210dacd3606d94ff8e61d99b477fd' -H 'Accept: application/json; charset=utf-8; indent=4' https://cloud.seafil
Sample response
...
< HTTP/1.0 200 OK
...
"success"
Errors
Note
Upload File
Get Upload Link
GET https://cloud.seafile.com/api2/repos/{repo-id}/upload-link/
Request parameters
repo-id
Sample request
Sample response
"http://cloud.seafile.com:8082/upload-api/ef881b22"
Errors
Upload File
After getting the upload link, POST to this link for uploading files.
POST http://cloud.seafile.com:8082/upload-api/ef881b22
Errors
Sample request
Sample response
"adc83b19e793491b1c6ea0fd8b46cd9f32e592fc"
Note
Update file
Get Update Link
GET https://cloud.seafile.com/api2/repos/{repo-id}/update-link/
Request parameters
repo-id
Sample request
Sample response
"http://cloud.seafile.com:8082/update-api/ef881b22"
Errors
Update File
After getting the upload link, POST to this link for uploading files.
POST http://cloud.seafile.com:8082/update-api/ef881b22
Request parameters
target_file
Sample request
Returns
Sample response
"adc83b19e793491b1c6ea0fd8b46cd9f32e592fc"
Errors
GET https://cloud.seafile.com/api2/repos/{repo-id}/upload-blks-link/
Request parameters
repo-id
Sample request
Sample response
"https://cloud.seafile.com/seafhttp/upload-blks-api/c1e6823d"
Errors
GET https://cloud.seafile.com/api2/repos/{repo-id}/update-blks-link/
Request parameters
repo-id
Sample request
curl -H "Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd" https://cloud.seafile.com/api2/repos/99b758e6-91ab-4265-b705-92536737
Sample response
"https://cloud.seafile.com/seafhttp/update-blks-api/c1e6823d"
Errors
Directory
GET https://cloud.seafile.com/api2/repos/{repo-id}/dir/
repo-id
p (optional): The path to a directory. If p is missing, then defaults to '/' which is the top directory.
oid (optional)
Sample request
Sample response
If oid is the latest oid of the directory, returns "uptodate" , else returns
[
{
"id": "0000000000000000000000000000000000000000",
"type": "file",
"name": "test1.c",
"size": 0
},
{
"id": "e4fe14c8cda2206bb9606907cf4fca6b30221cf9",
"type": "dir",
"name": "test_dir"
}
]
Errors
POST https://cloud.seafile.com/api2/repos/{repo-id}/dir/
repo-id
p
operation=mkdir (post)
Sample request
Sample response
...
< HTTP/1.0 201 CREATED
< Location: https://cloud.seafile.com/api2/repos/dae8cecc-2359-4d33-aa42-01b7846c4b32/dir/?p=/foo
...
"success"
Success
Response code 201(Created) is returned, and Location header provides the url of created directory.
Errors
Notes
Rename Directory
POST https://cloud.seafile.com/api2/repos/{repo-id}/dir/
Parameters
p (path)
operation=rename (post)
newname (the new name for directory)
Sample request
Success
Errors
Notes
If the new name is the same of the old name no operation will be done.
Delete Directory
DELETE https://cloud.seafile.com/api2/repos/{repo-id}/dir/
repo-id
p
Sample request
curl -X DELETE -v -H 'Authorization: Token f2210dacd3606d94ff8e61d99b477fd' -H 'Accept: application/json; charset=utf-8; indent=4' https://cloud.seafil
Sample response
...
< HTTP/1.0 200 OK
...
"success"
Success
Errors
Note
Download Directory
GET https://cloud.seafile.com/api2/repos/{repo-id}/dir/download/?p=/foo
repo-id
p
Sample request
Sample response
"https://cloud.seafile.com:8082/files/adee6094/foo"
Errors
400 Path is missing or invalid(e.g. p=/), or unable to download directory, size is too large
404 Repo(path) not found(exist)
520 Operation failed.
Share Directory
POST https://cloud.seafile.com/api2/repos/{repo-id}/dir/share/
repo-id
emails
s_type
path
perm
Sample request
Sample response
...
< HTTP/1.0 200 OK
...
Success
Batch Delete
Pipelining over HTTP/1.1 can be used to delete multiple files and directories without losing performance.
http://cloud.seafile.com/api2/repos/{repo-id}/dir/?p=/bar . This code snippet shows how to use Python client to batch delete
multiple files and directories. See http://cloud.seafile.com/f/f7fd5d5b9d/
Get Avatar
GET https://cloud.seafile.com/api2/avatars/user/{user}/resized/{size}/
Request parameters
user
size
Sample request
Sample response
{
"url": "http://127.0.0.1:8000/media/avatars/default.png",
"is_default": true,
"mtime": 0
}
GET https://cloud.seafile.com/api2/avatars/group/{group_id}/resized/{size}/
Request parameters
group_id
size
Sample request
Sample response
{
"url": "http://127.0.0.1:8000/media/avatars/groups/default.png",
"is_default": true,
"mtime": 0
}
List Group And Contacts
GET https://cloud.seafile.com/api2/groupandcontacts/
Sample request
Sample response
{
"contacts": [
{
"msgnum": 0,
"mtime": 0,
"lastmsg": null,
"email": "[email protected]",
"name": "123"
}
],
"umsgnum": 0,
"replynum": 0,
"groups": [
{
"ctime": 1398134171327948,
"creator": "[email protected]",
"msgnum": 0,
"mtime": 0,
"lastmsg": null,
"id": 1,
"name": "lian"
}
],
"gmsgnum": 0,
"newreplies": []
}
Get File Activities
GET https://cloud.seafile.com/api2/events/
Sample request
Sample response
{"more_offset": 16, "events":[{"repo_id": "6f3d28a4-73ae-4d01-a727-26774379dcb9", "author": "[email protected]", "nick": "lins05", "time": 13980789
Python API
Seafile Python API
Install Seafile Server
Example: Copy Library
Set Environment Variable
Copy Library
List Of Seafile-API
Seafile Python API
This tutorial show you how to use seafile-api, and will accomplish a "library copy" work under Ubuntu as example.
Install Seafile Server
First of all, make sure you have Download and Setup Seafile Server successfully. And your directory layout will be like
this:
# tree . -L 3
.
├── ccnet
│ ├── ccnet.conf
│ ├── ......
│......
├── seafile-server-3.0.3
│ ├── seafile
│ ├── seafile.sh
│ ├── seahub
│ ├── seahub.sh
│ ├── setup-seafile.sh
│ ├── upgrade
│ ├── README
│ ├── seaf_migrate_3.py
│ ├── seaf_migrate_3.sh
│ ├── ......
│ ├── ......
│......
Example: Copy Library
In this example, two script files will be used: seaf_migrate_3.sh and seaf_migrate_3.py . We put them in the upgrade
directory as you see above.
If you want use Seafile-API, set environment variable first. That's what seaf_migrate_3.sh does:
Example code
#!/bin/bash
export SEAFILE_CONF_DIR=$seafile_data_dir
}
export CCNET_CONF_DIR=${default_ccnet_conf_dir}
read_seafile_data_dir;
export PYTHONPATH=${INSTALLPATH}/seafile/lib/python2.6/site-packages:${INSTALLPATH}/seafile/lib64/python2.6/site-packages:${INSTALLPATH}
export PYTHONPATH=${INSTALLPATH}/seafile/lib/python2.7/site-packages:${INSTALLPATH}/seafile/lib64/python2.7/site-packages:$PYTHONPATH
function usage () {
echo "Usage: `basename $0` <repo-id>"
echo "exit."
exit 1
}
if [ $# != 1 ]; then
usage
fi
python seaf_migrate_3.py $1
NOTE: You can get repo_id at address bar of Seahub or through Seafile web API
Copy Library
Example code
#!/usr/bin/env python
import os
import stat
import sys
from seaserv import seafile_api
print "*" * 60
print "OK, verifying..."
print "Origin library(%s): %d files. New Library(%s): %d files." % (
origin_repo_id[:8], count_files_recursive(origin_repo_id),
new_repo_id[:8], count_files_recursive(new_repo_id))
print "*" * 60
If you execute script file successfully, you will see these output, and of course a new library at myhome page of Seahub.
seafile_api.add_inner_pub_repo()
seafile_api.cancel_copy_task()
seafile_api.change_repo_passwd()
seafile_api.check_passwd()
seafile_api.check_permission()
seafile_api.check_quota()
seafile_api.check_repo_access_permission()
seafile_api.copy_file()
seafile_api.count_inner_pub_repos()
seafile_api.create_enc_repo()
seafile_api.create_repo()
seafile_api.create_virtual_repo()
seafile_api.del_file()
seafile_api.delete_repo_token()
seafile_api.delete_repo_tokens_by_peer_id()
seafile_api.diff_commits()
seafile_api.edit_repo()
seafile_api.generate_repo_token()
seafile_api.get_commit_list()
seafile_api.get_copy_task()
seafile_api.get_decrypt_key()
seafile_api.get_deleted()
seafile_api.get_dir_id_by_commit_and_path()
seafile_api.get_dir_id_by_path()
seafile_api.get_file_id_by_commit_and_path()
seafile_api.get_file_id_by_path()
seafile_api.get_file_revisions()
seafile_api.get_file_size()
seafile_api.get_files_last_modified()
seafile_api.get_group_repo_list()
seafile_api.get_group_repoids()
seafile_api.get_group_repos_by_owner()
seafile_api.get_fileserver_access_token()
seafile_api.get_inner_pub_repo_list()
seafile_api.get_orphan_repo_list()
seafile_api.get_owned_repo_list()
seafile_api.get_repo()
seafile_api.get_repo_list()
seafile_api.get_repo_owner()
seafile_api.get_repo_size()
seafile_api.get_share_in_repo_list()
seafile_api.get_share_out_repo_list()
seafile_api.get_shared_groups_by_repo()
seafile_api.get_user_quota()
seafile_api.get_user_self_usage()
seafile_api.get_user_share_usage()
seafile_api.get_virtual_repo()
seafile_api.get_virtual_repos_by_owner()
seafile_api.group_share_repo()
seafile_api.group_unshare_repo()
seafile_api.is_inner_pub_repo()
seafile_api.is_password_set()
seafile_api.is_repo_owner()
seafile_api.is_valid_filename()
seafile_api.list_dir_by_commit_and_path()
seafile_api.list_dir_by_dir_id()
seafile_api.list_dir_by_path()
seafile_api.list_file_by_file_id()
seafile_api.list_repo_tokens()
seafile_api.list_repo_tokens_by_email()
seafile_api.move_file()
seafile_api.post_dir()
seafile_api.post_empty_file()
seafile_api.post_file()
seafile_api.put_file()
seafile_api.query_fileserver_access_token()
seafile_api.remove_inner_pub_repo()
seafile_api.remove_repo()
seafile_api.remove_share()
seafile_api.rename_file()
seafile_api.revert_dir()
seafile_api.revert_file()
seafile_api.revert_repo()
seafile_api.set_group_repo_permission()
seafile_api.set_passwd()
seafile_api.set_repo_owner()
seafile_api.set_share_permission()
seafile_api.set_user_quota()
seafile_api.share_repo()
seafile_api.unset_passwd()
Data Model
Seafile internally uses a data model similar to GIT's. It consists of Repo , Branch , Commit , FS , and Block .
Repo
A repo is also called a library. Every repo has an unique id (UUID), and attributes like description, creator, password.
Branch
Unlike git, only two predefined branches is used, i.e., local and master .
In PC client, modifications will first be committed to the local branch. Then the master branch is downloaded from server,
and merged into local branch. After that the local branch will be uploaded to server. Then the server will fast-forward its
master branch to the head commit of the just uploaded branch.
When users update a repo on the web, modifications will first be committed to temporary branch on the server, then
merged into the master branch.
Commit
Like in GIT.
FS
There are two types of FS objects, SeafDir Object and Seafile Object . SeafDir Object represents a directory, and Seafile
This mechanism makes it possible to deduplicate data between different versions of frequently updated files, improving
storage efficiency. It also enables transferring data to/from multiple servers in parallel.
Components of Seafile Server
Seafile server comprises of the following services.
Ccnet daemon (ccnet for client side or ccnet-server for server side):networking service daemon. In our initial
design, Ccnet worked like a traffic bus. All the network traffic between client, server and internal traffic between
different components would go through Ccnet. After further development we found that file transfer is improved by
utilizing the Seafile daemon component directly.
Seafile daemon:data service daemon
Seahub:the website. Seafile server package contains a light-weight Python HTTP server gunicorn that serves the
website. Seahub runs as an application within gunicorn.
FileServer: handles raw file upload/download functions for Seahub. Due to Gunicorn being poor at handling large
files, so we wrote this "FileServer" in the C programming language to serve raw file upload/download.
Controller: monitors ccnet and Seafile daemons, restarts them if necessary.
The picture below shows how Seafile desktop client syncs files with Seafile server:
The picture below shows how Seafile mobile client interacts with Seafile server:
The picture below shows how Seafile mobile client interacts with Seafile server if the server is configured behind
Nginx/Apache:
Synchronization algorithm
This article tries to give an overview on Seafile's file synchronization algorithm. For clarity, some details are deliberately
omitted, but it should help you get the big picture.
To better understand this article, you should first read [[Seafile data model]].
The Basic Work Flow
Each downloaded repo is bound to an ordinary local folder. Using Git's terminology, we call this local folder the
"worktree".
1. Seafile client daemon detects changes in the worktree (via inotify etc).
2. The daemon commits the changes to the local branch.
3. Download new changes from the master branch on the server (if any).
4. Merge the downloaded branch into local branch (also checkout changes to worktree).
5. Fast-forward upload local branch to server's master branch.
Since the above work flow may be interrupted at any point by shutting down the program or computer, after reboot we
lose all notifications from the OS. We need a reliable and efficient way to determine which files in the worktree has been
changed (even after reboots).
We use Git's index file to do this. It caches the timestamps of every file in the worktree when the last commit is generated.
So we can easily and reliably detect changed files in the worktree since the latest commit by comparing timestamps.
Another notable case is what happens if two clients try to upload to the server simultaneously. The commit procedure on
the server ensures atomicity. So only one client will update the master branch successfully, while the other will fail.
The failing client will restart the sync work flow later. It will first merge the changes from the succeeded client then upload
again.
Merge
The most tricky part of the syncing algorithm is merging.
Git's merge algorithm doesn't work well enough for auto synchronization.
Firstly, if a merge is interrupted, git requires you to reset to the latest commit and merge again. It's not a problem for Git
since it's a single command. But seafile runs as a daemon and may be kill at any time. The user may have changed some
files in the worktree between the interruption and restart. Resetting the worktree will LOSE user's uncommitted data.
Secondly, Git's merge command will fail if it fails to update a file in the worktree. But on Windows, an opened Office
document will be write-protected by the Office process. So the merge may fail in this case.
That's why programs use Git directly for auto-sync is not reliable.
Seafile implement its own merge algorithm based on the ideas from Git's merge algorithm.
It handles the first problem by "redoing" the merge carefully after restart. It handles the second problem by not starting
merge until no file is write-protected in the worktree.
Seafile's merge algorithm also handles all the conflict cases handled by Git.
Table of Contents
Introduction 2
Overview 2
Seafile Components 7
Roadmap 10
FAQ 12
Changelog 12
Contribution 15
Deploying Seafile under Linux 19
Deploying Seafile with SQLite 22
Deploying Seafile with MySQL 29
Config Seahub with Nginx 39
Enabling Https with Nginx 44
Config Seahub with Apache 48
Enabling Https with Apache 55
Configure Seafile to use LDAP 60
Start Seafile at System Bootup 65
Firewall settings 65
Logrotate 76
Add Memcached 76
Deploy Seafile behind NAT 81
Deploy Seahub at Non-root domain 87
Migrate From SQLite to MySQL 92
Common Problems for Setting up Server 94
Upgrade Seafile server 95
Deploy Seafile under Windows 99
Download and Setup Seafile Windows Server 102
Deploy Seafile with MySQL 104
Deploy Seafile with Apache 108
Deploy Seafile with Nginx 112
Install Seafile Server as a Windows Service 112
Ports used by Seafile Windows Server 116
Upgrading Seafile Windows Server 120
Deploy Seafile Pro Edition under Linux 125
Download and Setup Seafile Professional Server 130
Migrate from Seafile Community Server 134
Upgrading Seafile Professional Server 139
Setup With Amazon S3 143
Setup With OpenStackSwift 146
Setup With Ceph 151
Configurable Options 156
Use existing ElasticSearch server 158
Details about File Search 161
Deploy in a cluster 164
Enable search and background tasks in a cluster 173
Setup Seafile cluster with NFS 173
FAQ 178
License 180
Deploy Seafile Pro Edition under Windows 181
Download and Setup Seafile Windows Professional Server 183
Migrate from Seafile Community Server 188
Seafile WebDAV Server 193
Configurable Options 193
Server Configuration and Customization 199
Config and customize Email notifications 199
ccnet.conf 199
seafile.conf 203
seahub_settings.py 206
Seahub customization 210
sending_email 210
Customize Email Notifications 213
User management options 213
Administration 213
Account management 213
Logs 213
Backup and Recovery 222
Seafile FSCK 226
Seafile GC 227
WebDAV and FUSE extensions 227
WebDAV extension 231
FUSE extension 237
Security and Auditing 239
Security features 239
Access logs and auditing 239
Developing 239
How to Build Seafile 239
Linux 245
FreeBSD 248
Windows 248
Max OS X 252
Server 259
Develop env 267
Code Standard 267
Web API 272
Python API 320
Data Model 327
Server Components 327
Sync algorithm 334