Seafile Server Manual

Download as pdf or txt
Download as pdf or txt
You are on page 1of 339

Introduction

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

3.1 (To be released before 2014.7.30)

Version 3.1 will focus on improving the file syncing algorithm. Including

Improve performance: easily syncing 10k+ files in a library.


Don't need to download files if they are moved to another directory.

Platform

Add OAuth support for easy integrating into other systems


Enable creating sub-libraries from an encrypted library
Rename FileServer to FileServer to remove confusing.

Web

Enable deleting of personal messages


Improved notification
Upgrade pdf.js
Password protection for sharing links
More details
Seafile roadmap for 3-x
Seafile roadmap for 2-x
FAQ

When downloading a library, the client hangs at "connecting server"

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:

Manually telnet to see if you can connect: telnet your-server-IP-or-domain 10001

Failed to upload/download file online

Make sure you firewall for seafile fileserver is opened.


Using chrome/firefox debug mode to find which link is given when click download button and what's wrong with this
link

Does Seafile server support Python 3?

No, You must have python 2.6.5+ or 2.7 installed on your server.

Can Seafile server run on FreeBSD?

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.)

Website displays "Page unavailable", what can I do?

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

Avatar pictures vanished after upgrading server, what can I do?

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/*

How to change seafile-data location after setup?

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.

Failed to send email, what can I do?

Please check logs/seahub.log.


There are some common mistakes:

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.

Client stops syncing, needs download library again

Please check issue https://github.com/haiwen/seafile/issues/730


Changelog

v3.0.4 Server

[API] Add replace if exist into upload-api


Show detailed error message when Gunicorn failed to start
Improve object and block writting performance
Add retry when failed getting database connection

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

IRC: #seafile on freenode

Follow us @seafile https://twitter.com/seafile


Reporting a Bug?
Find the existing issues that fit your situation if any, or create a new issue. We are using github as our issue tracer
https://github.com/haiwen/seafile/issues?state=open
Join us on Google Group: https://groups.google.com/forum/?fromgroups#!forum/seafile
Code Style
The source code of seafile is ISO/IEC 9899:1999 (E) (a.k.a. C99) compatible. Take a look at code standard.
Deploying Seafile under Linux
Here we describe how to deploy Seafile from prebuild binary packages.

Deploy Seafile in Home/Personal Environment

Deploying Seafile with SQLite

Deploy Seafile in Production/Enterprise Environment

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:

Deploying Seafile with MySQL


Config Seahub with Nginx
Enabling Https with Nginx
Config Seahub with Apache
Enabling Https with Apache

Advanced:

Configure Seafile to use LDAP


Start Seafile at System Bootup
Firewall settings
Logrotate
Add Memcached

Other Deployment Issues

Deploy Seafile behind NAT


Deploy Seahub at Non-root domain
Migrate From SQLite to MySQL

Check configuration options for server config options like enabling user registration.

Read here if you have troubles setting up Seafile server

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

Download binary package


Visit our download page, download the latest server package.

Choose one of:

Generic Linux
Windows
Server for Raspberry Pi

#check if your system is x86 (32bit) or x86_64 (64 bit)


uname -m

Click the tarball link and save it.


Deploying and Directory Layout
NOTE: If you place the Seafile data directory in external storage, such as NFS, CIFS mount, you should not use SQLite as
the database, but use MySQL instead.

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

Now you should have the following directory layout

# 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

The benefit of this layout is that

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

python 2.6.5+ or 2.7


python-setuptools
python-simplejson
python-imaging
sqlite3

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

Seafile configuration options

Option Description Note

server 3-15 characters, only English letters, digits and underscore


Name of this seafile server
name ('_') are allowed

server ip
The IP address or domain name Seafile client program will access the server with this
or
used by this server address
domain

ccnet The TCP port used by ccnet, the


Default is 10001. If it's been used by other service, you can
server underlying networking service of
set it to another port.
port Seafile

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.

Now you should have the following directory layout :


#tree haiwen -L 2
haiwen
├── ccnet # configuration files
│ ├── ccnet.conf
│ ├── mykey.peer
│ ├── PeerMgr
│ └── seafile.ini
├── installed
│ └── seafile-server_1.4.0_x86-64.tar.gz
├── seafile-data
│ └── seafile.conf
├── seafile-server-1.4.0 # 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.4.0
├── seahub-data
│ └── avatars
├── seahub.db
├── 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

Starting Seafile Server and Seahub Website

Start seafile:

./seafile.sh start # Start seafile service

Start seahub:

./seahub.sh start <port> # Start seahub website, port defaults to 8000

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.

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

restart seafile server

./seafile.sh start
./seahub.sh start 8001

see Seafile Server Configuration Manual for more details about ccnet.conf .
Manage Seafile and Seahub

Stopping

./seahub.sh stop # stop seahub website


./seafile.sh stop # stop seafile processes

Restarting

./seafile.sh restart
./seahub.sh restart

When the Scripts Fail

Most of the time, seafile.sh and seahub.sh work fine. But if they fail, you may

Use pgrep command to check if seafile/seahub processes are still running

pgrep -f seafile-controller # check seafile processes


pgrep -f "manage.py run_gunicorn" # check seahub process

Use pkill to kill the processes

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.

#check if your system is x86 (32bit) or x86_64 (64 bit)


uname -m

For Seafile Server 2.1.4 and later:

#download for 32bit


https://bitbucket.org/haiwen/seafile/downloads/seafile-server_{version}_i386.tar.gz
#or for 64bit
https://bitbucket.org/haiwen/seafile/downloads/seafile-server_{version}_x86-64.tar.gz
Deploying and Directory Layout
Supposed your organization's name is "haiwen", and you've downloaded seafile-server1.8.2* 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

Now you should have the following directory layout

#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

'''The benefit of this layout is that'''

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.

There are two ways to intialize the databases:

let the setup-seafile-mysql.sh script create the databases for you.


create the databases by yourself, or someone else (the database admin, for example)

We recommend the first way. The script would ask you for the root password of the mysql server, and it will create:

database for ccnet/seafile/seahub.


a new user to access these databases

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:

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


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

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

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


GRANT ALL PRIVILEGES ON `seafile-db`.* to `seafile`;
GRANT ALL PRIVILEGES ON `seahub-db`.* to `seafile`;
Setting Up Seafile Server

Prerequisites

The Seafile server package requires the following packages have been installed in your system

python 2.6.5+ or 2.7


python-setuptools
python-simplejson
python-imaging
python-mysqldb

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

Seafile configuration options

Option Description Note

server 3-15 characters, only English letters, digits and underscore


Name of this seafile server
name ('_') are allowed

server ip
The IP address or domain name Seafile client program will access the server with this
or
used by this server address
domain

ccnet The TCP port used by ccnet, the


Default is 10001. If it's been used by other service, you can
server underlying networking service of
set it to another port.
port Seafile

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:
-------------------------------------------------------

[1] Create new ccnet/seafile/seahub databases


[2] Use existing ccnet/seafile/seahub databases

Which one to choose depends on if you have the root password.

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:

You'll see these output:

Question Description Note

mysql server host the host address of the mysql server the default is localhost

the default is 3306. Almost every mysql


mysql server port the port of the mysql server
server uses this port.

the root password is required to create new


root password the password of mysql root account
databases and a new user

mysql user for the username for seafile programs to use


if the user does not exist, it would be created
seafile to access MySQL server

password for
the password for the user above
seafile mysql user

ccnet dabase the name of the database used by ccnet,


the database would be created if not existing
name default is "ccnet-db"

seafile dabase the name of the database used by seafile,


the database would be created if not existing
name default is "seafile-db"

seahub dabase the name of the database used by


the database would be created if not existing
name seahub, default is "seahub-db"

If you choose "[2] Use existing ccnet/seafile/seahub databases", you would be asked these questions:

You'll see these output:

related questions for "Use existing ccnet/seafile/seahub databases"

Question Description Note

mysql server host the host address of the mysql server the default is localhost

the default is 3306. Almost every mysql


mysql server port the port of the mysql server
server uses this port

mysql user for the user for seafile programs to use to


the user must already exists
seafile access MySQL server

password for seafile


the password for the user above
mysql user

ccnet dabase name the name of the database used by ccnet this database must already exist

seafile dabase the name of the database used by seafile,


this database must already exist
name default is "seafile-db"

seahub dabase the name of the database used by seahub,


name default is "seahub-db" this database must already exist

If the setup is successful, you'll see the following output

Now you should have the following directory layout :

#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

Starting Seafile Server and Seahub Website

Under seafile-server-1.8.2 directory, run the following commands

Start seafile:

./seafile.sh start # Start seafile service

Start seahub

./seahub.sh start # Start seahub website, port defaults to 8000

'''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

restart seafile server

./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

./seahub.sh stop # stop seahub website


./seafile.sh stop # stop seafile processes

Restarting

./seafile.sh restart
./seahub.sh restart

When the Scripts Fail

Most of the time, seafile.sh and seahub.sh work fine. But if they fail, you may

Use '''pgrep''' command to check if seafile/seahub processes are still running

pgrep -f seafile-controller # check seafile processes


pgrep -f "manage.py run_gunicorn" # check seahub process

Use '''pkill''' to kill the processes

pkill -f seafile-controller
pkill -f "manage.py run_gunicorn"
That's it!
That's it! Now you may want read more about seafile.

Deploy Seafile with Nginx / Deploy Seafile with Apache


Enable Https on Seafile Web with Nginx / Enable Https on Seafile Web with Apache
Configure Seafile to use LDAP
How to manage the server
Config Seahub with Nginx

Prepare
Install python-flup library. On Ubuntu:

sudo apt-get install python-flup


Deploy Seahub/FileServer with Nginx
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'''.

This is a sample Nginx config file.

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;

fastcgi_param SERVER_PROTOCOL $server_protocol;


fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
fastcgi_param REMOTE_ADDR $remote_addr;

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.

In this case, you can write:

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.

Generate SSL digital certificate with OpenSSL

openssl genrsa -out privkey.pem 2048


openssl req -new -x509 -key privkey.pem -out cacert.pem -days 1095

Enable SSL module of Nginx (optional)

If your Nginx does not support SSL, you need to recompile it, the commands are as follows:

./configure --with-http_stub_status_module --with-http_ssl_module


make && make install

Modify Nginx configuration file

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

Sample configuration file

Here is the sample 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;
location / {
fastcgi_pass 127.0.0.1:8000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_script_name;

fastcgi_param SERVER_PROTOCOL $server_protocol;


fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
fastcgi_param HTTPS on;
fastcgi_param HTTP_SCHEME https;

access_log /var/log/nginx/seahub.access.log;
error_log /var/log/nginx/seahub.error.log;
}
location /seafhttp {
rewrite ^/seafhttp(.*)$ $1 break;
proxy_pass http://127.0.0.1:8082;
client_max_body_size 0;
}
location /media {
root /home/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:

sudo apt-get install python-flup

2. Install and enable mod_fastcgi and also enable mod_rewrite. On Ubuntu:

sudo apt-get install libapache2-mod-fastcgi


sudo a2enmod rewrite
sudo a2enmod fastcgi

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.:

deb http://ftp.debian.org/pub/debian/ wheezy main non-free


deb-src http://ftp.debian.org/pub/debian/ wheezy main non-free

deb http://security.debian.org/ wheezy/updates main non-free


deb-src http://security.debian.org/ wheezy/updates main non-free

3. Enable apache proxy

sudo a2enmod proxy_http

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:

apache2.conf , for ubuntu/debian:

FastCGIExternalServer /var/www/seahub.fcgi -host 127.0.0.1:8000

httpd.conf , for centos/fedora:

FastCGIExternalServer /var/www/html/seahub.fcgi -host 127.0.0.1:8000

httpd.conf , for Windows:

LoadModule fastcgi_module modules/mod_fastcgi-2.4.6-AP22.dll


LoadModule rewrite_module modules/mod_rewrite.so
FastCGIExternalServer e:/seafile-server-1.7.1/seahub/seahub.fcgi -host 127.0.0.1:8000

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

sudo service apache2 restart


./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:

Alias /media /home/user/haiwen/seafile-server-1.4.0/seahub/media

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.

In this case, you can write:

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

FastCGIExternalServer /var/www/seahub.fcgi -host 127.0.0.1:8000

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:

ProxyPass /seafhttp http://127.0.0.1:8082


ProxyPassReverse /seafhttp http://127.0.0.1:8082
RewriteRule ^/seafhttp - [QSA,L]
Enabling Https with Apache

Generate SSL digital certificate with OpenSSL


Here we use self-signed SSL digital certificate for free. If you use a paid ssl certificate from some authority, just skip the
this step.

openssl genrsa -out privkey.pem 2048


openssl req -new -x509 -key privkey.pem -out cacert.pem -days 1095
Enable https on Seahub
Assume you have configured Apache as Deploy Seafile with Apache. To use https, you need to enable mod_ssl

[sudo] a2enmod ssl

On Windows, you have to add ssl module to httpd.conf

LoadModule ssl_module modules/mod_ssl.so

Then modify your Apache configuration file. Here is a sample:

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

FastCGIExternalServer /var/www/seahub.fcgi -host 127.0.0.1:8000

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:

ProxyPass /seafhttp http://127.0.0.1:8082


ProxyPassReverse /seafhttp http://127.0.0.1:8082
RewriteRule ^/seafhttp - [QSA,L]
Configure Seafile to use LDAP
The current code of seahub assumes that user name to be email address, so it's not possible to log in with UNIX user
names or Windows Domain user names now. The support may be added later.

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

Example config for LDAP:

[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

Example config for Active Directory:

[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

Example config for LDAP:

[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

Example config for Active Directory:

[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.

Here is another example:

FILTER = &(!(UserAccountControl:1.2.840.113556.1.4.803:=2))
Known Issues

ldaps (LDAP over SSL) doesn't work on Ubuntu/Debian

Please see https://github.com/haiwen/seafile/issues/274

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.

The work around is

mkdir /etc/openldap && ln -s /etc/ldap/ldap.conf /etc/openldap/


Start Seafile at System Bootup

For Ubuntu
On Ubuntu, we make use of the /etc/init.d/ scripts to start seafile/seahub at system boot.

Create a script /etc/init.d/seafile-server

sudo vim /etc/init.d/seafile-server

The content of this script is: (You need to modify the value of user and seafile_dir accordingly)

#!/bin/bash

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


user=haiwen

# Change the value of "seafile_dir" to your path of seafile installation


seafile_dir=/data/haiwen
script_path=${seafile_dir}/seafile-server-latest
seafile_init_log=${seafile_dir}/logs/seafile.init.log
seahub_init_log=${seafile_dir}/logs/seahub.init.log

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


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

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

Add Directory for Logfiles

mkdir /path/to/seafile/dir/logs

Create a file /etc/init/seafile-server.conf


If you're not using MySQL

start on (runlevel [2345])


stop on (runlevel [016])

pre-start script
/etc/init.d/seafile-server start
end script

post-stop script
/etc/init.d/seafile-server stop
end script

If you're using MySQL

start on (started mysql


and runlevel [2345])
stop on (runlevel [016])

pre-start script
/etc/init.d/seafile-server start
end script

post-stop script
/etc/init.d/seafile-server stop
end script

Make the seafile-sever script executable

sudo chmod +x /etc/init.d/seafile-server

Done

Don't forget to update the value of script_path later if you update your seafile server.
For other Debian based Linux

Create a script /etc/init.d/seafile-server

sudo vim /etc/init.d/seafile-server

The content of this script is: (You need to modify the value of user and script_path accordingly)

#!/bin/sh

### BEGIN INIT INFO


# Provides: seafile-server
# Required-Start: $local_fs $remote_fs $network
# Required-Stop: $local_fs
# Default-Start: 2345
# Default-Stop: 016
# Short-Description: Starts Seafile Server
# Description: starts Seafile Server
### END INIT INFO

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


user=haiwen

# Change the value of "script_path" to your path of seafile installation


seafile_dir=/data/haiwen
script_path=${seafile_dir}/seafile-server-latest
seafile_init_log=${seafile_dir}/logs/seafile.init.log
seahub_init_log=${seafile_dir}/logs/seahub.init.log

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


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

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:

# Required-Start: $local_fs $remote_fs $network mysql


Add Directory for Logfiles

mkdir /path/to/seafile/dir/logs

Make the seafile-sever script executable

sudo chmod +x /etc/init.d/seafile-server

Add seafile-server to rc.d

sudo update-rc.d seafile-server defaults

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.

Locate your python executable (python 2.6 or 2.7)

which python2.6 # or "which python2.7"

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/

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


user=haiwen

# Change the value of "script_path" to your path of seafile installation


seafile_dir=/data/haiwen
script_path=${seafile_dir}/seafile-server-latest

sudo -u ${user} ${script_path}/seafile.sh start > /tmp/seafile.init.log 2>&1


sudo -u ${user} ${script_path}/seahub.sh start > /tmp/seahub.init.log 2>&1

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.

Create a file /etc/sysconfig/seafile

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


user=haiwen

# Change the value of "script_path" to your path of seafile installation


seafile_dir=/home/haiwen
script_path=${seafile_dir}/seafile-server-latest
seafile_init_log=${seafile_dir}/logs/seafile.init.log
seahub_init_log=${seafile_dir}/logs/seahub.init.log

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


fastcgi=false

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

Create a script /etc/init.d/seafile


#!/bin/bash
#
# seafile

#
# chkconfig: - 68 32
# description: seafile

# Source function library.


. /etc/init.d/functions

# Source networking configuration.


. /etc/sysconfig/network

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

RETVAL=0

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

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

# See how we were called.


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

exit $RETVAL

Create a script /etc/init.d/seahub


#!/bin/bash
#
# seahub

#
# chkconfig: - 69 31
# description: seahub

# Source function library.


. /etc/init.d/functions

# Source networking configuration.


. /etc/sysconfig/network

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

RETVAL=0

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

stop() {
echo -n $"Shutting down 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
}

# See how we were called.


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

exit $RETVAL

Next, enable services:

chmod 550 /etc/init.d/seafile


chmod 550 /etc/init.d/seahub
chkconfig --add seafile
chkconfig --add seahub
chkconfig seahub on
chkconfig seafile on
and run:

service seafile start


service seahub start
For systems running systemd
Create systemd service files, change ${seafile_dir} to your seafile installation location and seafile to user, who runs
seafile (if appropriate). Then you need to reload systemd's daemons: systemctl daemon-reload.

Create systemd service file /etc/systemd/system/seafile.service

[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

Create systemd service file /etc/systemd/system/seahub.service

[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

Create systemd service file /etc/systemd/system/seafile-client.service (optional)

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 :

The configuration for logroate could be like this:

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

You can save this file, for example in debian, to /etc/logrotate.d/seafile


That's it
You now gets all the things done, just sit and enjoy your time :-D
Add 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',
}
}
Deploy Seafile behind NAT
A lot of people want to deploy a seafile server in their LAN, and access it from the WAN.

To achieve this, you need:

A router which supports port forwarding


Use a dynamic DNS Service
Modify your seafile server configuration

Table of Contents

Setup the server


Setup port forwarding in your router
Use a dynamic dns serivce
Modify your seafile configuration
Setup the server
First, you should follow the guide on Download and Setup Seafile Server to setup your Seafile server.

Before you continue, make sure:

You can visit your seahub website


You can download/sync a library through your seafile client
Setup Port Forwarding in Your Router

Ensure Your Router Supports Port Forwarding

First, ensure your router supports port forwarding.

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.

Setup Port Forwarding Rules

Seafile server is composed of several components. You need to configure port forward for all the components listed
below.

component default port

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.

How to test if your port forwarding is working

After you have set the port forwarding rules on your router, you can check whether it works by:

Open a command line prompt


Get your WAN IP. A convenient way to get your WAN ip is to visit http://who.is , which would show you your WAN IP.
Try to connect your seahub server

telnet <Your WAN IP> 8000

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.

If your port forwarding is not working, the reasons may be:

You have configured a wrong port forwarding


Your router may need a restart
You network may be down

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.

SERVICE_URL = http://<Your WAN IP>:8000


Most routers support NAT loopback. When your access Seafile web from intranet, file download/upload still works even
when external IP is used.
Use a Dynamic DNS Serivce

Why use a Dynamic DNS(DDNS) Service?

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:

1. Choose a DDNS service provider


2. Register an account on the DDNS service provider's website
3. Download a client from your DDNS service provider to keep your domain name always mapped to your WAN IP
Modify your seafile configuration
After you have setup your DDNS service, you need to modify the ccnet.conf :

SERVICE_URL = http://<Your dynamic DNS domain>:8000

Restart your seafile server after this.


Deploy Seahub at Non-root domain
This documentation will talk about how to deploy Seafile Web using Apache/Nginx at Non-root directory of the
website(e.g., www.example.com/seafile/).

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/ .

Then, we need to configure the Nginx:

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;

fastcgi_param SERVER_PROTOCOL $server_protocol;


fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
# fastcgi_param HTTPS on; # enable this line only if https is used
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 /seafmedia {
rewrite ^/seafmedia(.*)$ /media$1 break;
root /home/user/haiwen/seafile-server-latest/seahub;
}
}

You need also to modify SERVICE_URL and FILE_SERVER_ROOT (see below).


Deploy with Apache
First, you need to modify seahub_settings.py as above.

Then edit httpd.conf file, add this line:

FastCGIExternalServer /var/www/seahub.fcgi -host 127.0.0.1:8000

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

You need to add a line in seahub_settings.py to set the value of FILE_SERVER_ROOT

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.

Steps to migrate Seafile from SQLite to MySQL:

1. Stop seafile and seahub

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

This script will produce three files(ccnet-db.sql, seafile-db.sql, seahub-db.sql).

4. Create 3 databases named ccnet-db , seafile-db , seahub-db .

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


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

5. Loads the sql files to your MySQL databases. For example:

mysql> use `ccnet-db`


mysql> source ccnet-db.sql
mysql> use `seafile-db`
mysql> source seafile-db.sql
mysql> use `seahub-db`
mysql> source seahub-db.sql

6. Modify configure files

Append following lines to ccnet/ccnet.conf :

[Database]
ENGINE=mysql
HOST=127.0.0.1
USER=root
PASSWD=root
DB=ccnet-db
CONNECTION_CHARSET=utf8

Note: Use 127.0.0.1 , don't use localhost .

Replace the database section in seafile-data/seafile.conf with following lines:

[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",
}
}
}

7. Restart seafile and seahub


Common Problems for Setting up Server

Failed to upload/download file online

Check your SERVICE_URL setting in ccnet.conf and FILE_SERVER_ROOT setting in seahub_settings.py


Make sure you firewall for seafile fileserver is opened.
Using chrome/firefox debug mode to find which link is given when click download button and what's wrong with this
link

When syncing a library, the client hangs at "connecting server"

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:

Manually telnet to see if you can connect: telnet your-server-IP-or-domain 10001

Failed to download blocks

Make sure port 12001 is open

Error on Apache log: "File does not exist: /var/www/seahub.fcgi"

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:

1. Run installation script as non-root user


2. Copy /media folder to var/www/ and edit the Alias location in /etc/apache2/sites-enabled/000-default

"Error when calling the metaclass bases" during Seafile initialization

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

Now upgrade to version 3.1.0.

1. Shutdown Seafile server if it's running

cd haiwen/seafile-server-2.1.0
./seahub.sh stop
./seafile.sh stop

2. Check the upgrade scripts in seafile-server-3.1.0 directory.

cd haiwen/seafile-server-3.1.0
ls upgrade/upgrade_*

You will get a list of upgrade files:

...
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

4. Start the new server version as for any upgrade

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

Now upgrade to version 3.2.2.

1. Shutdown Seafile server if it's running

cd haiwen/seafile-server-3.0.0
./seahub.sh stop
./seafile.sh stop

2. Check the upgrade scripts in seafile-server-3.2.2 directory.

cd haiwen/seafile-server-3.2.2
ls upgrade/upgrade_*

You will get a list of upgrade files:

...
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

4. Start the new server version as for any upgrade

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.

1. Stop the current server first as for any upgrade


2. For this type of upgrade, you only need to update the avatar link. We provide a script for you, just run it (For history
reason, the script called minor-upgrade.sh ):

cd seafile-server-3.1.2
upgrade/minor-upgrade.sh

3. Start the new server version as for any upgrade

4. If the new version works file, the old version can be removed

rm -rf seafile-server-3.1.0
Deploy with Windows

Setup and Upgrade


Seafile Windows Community Edition supports SQLite/MySQL database. The Seafie Windows professional edition
supports WebDAV and File Search.

Download and Setup Seafile Windows Server


Deploy Seafile with MySQL
Deploy Seafile with Apache
Deploy Seafile with Nginx
LDAP Integration
Install Seafile Server as a Windows Service
Ports used by Seafile Windows Server
Upgrading Seafile Windows Server
Options & Customization

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.

"ERROR: D:/seafile-server\seahub.db not found"

This file is created during Seafile initialization. Please:

Check whether your Python and the PATH for Python is correctly set.
Put Seafile server package in a simple path, like C:\seafile-packages .

Failed to create seahub.db

Use python version 2.7.4 32bit, do not use python 3+.

Can not upload/download files in the Web interface

Make sure you have modified SERVICE_URL in ccnet.conf.

The browser can't get the css and javascript files

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

Install Python 2.7.4 32bit

Download and install python 2.7.4 32bit


Add the installation path of python2.7 to the system PATH environment variable. If you installed python 2.7 to
C:\Python27 add C:\Python27 to the PATH environment variable

Download/Uncompress Seafile Server

Get the latest version of Seafile Server program


Create a new folder to store seafile program, such as C:\SeafileProgram\ . Please remember the location of the folder,
we'll use it later.
Uncompress seafile-server_1.7.0_win32.tar.gz to C:\SeafileProgram\

Now you have a folder like this:

C:\SeafileProgram
|__ seafile-server-1.7.0
Start/Initialization

Start Seafile Server

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

Please choose a disk with enough free space


Once you clicked the OK button, Seafile would create a folder named seafile-server under the disk you choosed.
That would be the data folder of Seafile Server. If you choose disk D, your data folder would be D:\seafile-server

Add an admin account

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

Configure Seafile Server

After initialization, there are some options need to be configured:

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

You may also want to read about:

Deploy Seafile with MySQL


Deploy Seafile with Apache
Deploy Seafile with Nginx
LDAP Integration
Install Seafile Server as a Windows Service
Ports used by Seafile Windows Server
Upgrading Seafile Windows Server
Options & Customization
Deploy Seafile Windows Server With MySQL

Preparation
Download and Setup Seafile Windows Server
Stop seafile windows server
Right click the seafile server tray icon
Choose "Quit and shutdown Seafile Server"

Make sure your MySQL server is running

Install MySQL-python Library

download the windows installer from https://pypi.python.org/pypi/MySQL-python/1.2.4


install it by double clicking the downloaded exe file
Create MySQL Databases
You need to create:

databases for ccnet/seafile/seahub


a new user to access these databases

Execute these SQL setences on your mysql server:

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


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

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

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


GRANT ALL PRIVILEGES ON `seafile-db`.* to `seafile`;
GRANT ALL PRIVILEGES ON `seahub-db`.* to `seafile`;
Modify Your Seafile Configuations
Append the following lines to ccnet/ccnet.conf:

[Database]
ENGINE=mysql
HOST=localhost
USER=seafile
PASSWD=seafile
DB=ccnet-db

Edit the database section of seafile-data/seafile.conf:

[database]
type=mysql
host=localhost
user=seafile
password=seafile
db_name=seafile-db

Append following lines to seahub_settings.py

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME' : 'seahub-db',
'USER' : 'seafile',
'PASSWORD' : 'seafile',
'HOST' : 'localhost',
}
}

Edit the DATABASE section of seafile-server/pro-data/seafevents.conf

[DATABASE]
type=mysql
username=seafile
password=seafile
name=seahub-db
host=127.0.0.1
port=3306

Create Database Tables for Seahub

Now we create the database tables for seahub.

Assume you have uncompressed seafile server to C:/SeafileProgram/seafile-pro-server-3.1.3 ,

Open a window command line prompt, and execute the following command:

mysql seahub-db < C:/SeafileProgram/seafile-server-3.1.3/seahub/sql/mysql.sql


Done
Now you can start your seafile server.
Deploy Seafile with Apache

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:

LoadModule fastcgi_module modules/mod_fastcgi-2.4.6-AP22.dll


LoadModule rewrite_module modules/mod_rewrite.so
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
Include conf/extra/httpd-vhosts.conf

Then add this line (substitute YourDocumentRoot with the value of your apache DocumentRoot )

FastCGIExternalServer "YourDocumentRoot/seahub.fcgi" -host 127.0.0.1:8000

Note, seahub.fcgi is just a placeholder, you don't need to actually have this file in your system.

Edit your httpd-vhosts.conf

Assume you have uncompresssed seafile server into C:/SeafileProgram/seafile-pro-server-2.1.4 .

<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

Modify the seahub section of seafile-data/seafile.conf :

[seahub]
port=8000
fastcgi=true

Modify seahub_settings.py

You need to add a line in seahub_settings.py to set the value of FILE_SERVER_ROOT

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

Deploy Seahub/FileServer with Nginx


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'''.

This is a sample Nginx config file.

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;

fastcgi_param SERVER_PROTOCOL $server_protocol;


fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
fastcgi_param REMOTE_ADDR $remote_addr;

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

Modify the seahub section of seafile-data/seafile.conf :

[seahub]
port=8000
fastcgi=true

Modify seahub_settings.py

You need to add a line in seahub_settings.py to set the value of FILE_SERVER_ROOT

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

Why you may want to install Seafile Server as a Windows service

Seafile Server can keep on running after all users logout


When system boots up, Seafile Server would start running even if no user has logged in

Install as a service

Right click the tray icon, choose Install as a Windows service


Choose yes in the propmted dialog

If the operation succeeds, A dialog would be prompted saying Successully installed seafile service.

Verify Seafile Server already running as a Windows service

Logout the current user


Visit seahub from another computer. If the seahub website can still be visited, Seafile server is already running as a
Windows server

How to start the tray icon after installing as a 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

If you want to uninstall the Seafile Server service:

Right click the tray icon, choose "Uninstall Windows service"


Choose "yes" in the propmted dialog
Ports used by Seafile Windows Server
Seafile server has several components, so several TCP ports are used.
The two configuration files
All ports related configuration are recorded in ccnet.conf and seafile.conf .

How to open ccnet.conf

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.

How to open seafile.conf

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

seafile fileserver handles raw file upload/download for Seahub

default: 8082
How to change: Edit the file seafile.conf . Change the value of port under the fileserver section.

[fileserver]
port=8082

seahub

seahub is the web interface of seafile server.

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

Note:You must shutdown seafile server before you upgrade.


Uncompress the new version of Seafile Server
Before you upgrade, assume you have:

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

Move the contents of the avatars folder

Go to the folder seafile-server-3.0.0/seahub/media/avatars

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:

Run the major upgrade script

Run the database upgrade script

Go to seafile-server-3.1.y/upgrade
Right click the file upgrade_3.0_3.1.bat

Choose "run as administrator"

If you're using MySQL, you need to manually upgrade the database yourself:

Go to the folder seafile-server-3.1.y/upgrade/sql/3.1.0/mysql/


If there are a file ccnet.sql , run it with the ccnet-db database

mysql ccnet-db < ccnet.sql

If there are a file seafile.sql , run it with the seafile-db database

mysql ccnet-db < seafile.sql

If there are a file seahub.sql , run it with the seahub-db database

mysql seahub-db < seafile.sql

Copy avatars

Copy all subfolders of seafile-server-3.0.0/seahub/media/avatars to seafile-server-3.1.0/seahub/media/avatars


Upgrading Windows Service
If you have installed Seafile server as a Windows Service, you need to:

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

Download and Setup Seafile Professional Server


Migrate from Seafile Community Server
Upgrading Seafile Professional Server

S3/OpenSwift/Ceph

Setup Seafile Professional Server With Amazon S3


Setup Seafile Professional Server With OpenStackSwift
Setup Seafile Professional Server With Ceph

Config Options

Seafile Professional Server Configurable Options


Search
Use existing ElasticSearch server
Details about File Search
Cluster
Deploy seafile servers in a cluster
Enable search and background tasks in a cluster
FAQ
FAQ For Seafile Professional Server
License
Seafile Professional Edition Software License Agreement
Download and Setup Seafile Professional Server

Preparation

Minimum System Requirement

A Linux server with 2GB RAM

Install Java Runtime Environment (JRE)

On Ubuntu/Debian:

sudo apt-get install default-jre

On CentOS/Red Hat:

sudo yum install java-1.6.0-openjdk

Note: You can use either the JRE of openJDK or Oracle JRE, but not the GCJ(GNU Java) package.

Install poppler-utils

We need poppler-utils for full text search of pdf files.

On Ubuntu/Debian:

sudo apt-get install poppler-utils

On CentOS/Red Hat:

sudo yum install poppler-utils

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:

sudo apt-get install libreoffice python-uno

On Centos/RHEL:

sudo yum install libreoffice libreoffice-headless libreoffice-pyuno

For other Linux distro: Installation of LibreOffice on Linux

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

Install Python libraries

First make sure your have installed python 2.6 or 2.7

sudo easy_install pip


sudo pip install boto

If you receive an error about "Wheel installs require setuptools >= ...", run this between the pip and boto lines above

sudo pip install setuptools --no-use-wheel --upgrade

Install other libraries as required in the community edition

See Download and Setup Seafile Server With MySQL.


Download and Setup Seafile Professional Server

Get the license

Put the license you get under the top level diretory. In our wiki, we use the diretory /data/haiwen/ as the top level directory.

Download/Uncompress Seafile Professional Server

tar xf seafile-pro-server_1.8.0_x86-64.tar.gz

Now you have:

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.

You may want to read more about Seafile Professional Server:

Setup Seafile Professional Server With Amazon S3


FAQ For Seafile Professional Server
Migrate from Seafile Community Server

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

Install Java Runtime Environment (JRE)

On Ubuntu/Debian:

sudo apt-get install default-jre

On CentOS/Red Hat:

sudo yum install java-1.6.0-openjdk

Note: You can use either the JRE of openJDK or Oracle JRE, but not the GCJ(GNU Java) package.

Install poppler-utils

We need poppler-utils for full text search of pdf files.

On Ubuntu/Debian:

sudo apt-get install poppler-utils

On CentOS/Red Hat:

sudo yum install poppler-utils

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:

sudo apt-get install libreoffice python-uno

On Centos/RHEL:

sudo yum install libreoffice libreoffice-headless libreoffice-pyuno

For other Linux distro: Installation of LibreOffice on Linux

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 .

Get the license

Put the license you get under the top level directory of your Seafile installation. In our example, it is /data/haiwen/ .

Download/Uncompress Seafile Professional Server

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

Now you have:

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

Stop Seafile Community Server if it's running

cd haiwen/seafile-server-1.8.0
./seafile.sh stop
./seahub.sh stop

Run the migration script

cd haiwen/seafile-pro-server-1.8.0/
./pro/pro.py setup --migrate

The migration script would do the following for you:

ensure your have all the prerequisites met


create necessary extra configurations
update the avatar directory
create extra database tables

Now you have:


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
└── pro-data/

Start Seafile Professional Server

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

Update the avatar directory link just like in Minor Upgrade

cd haiwen/seafile-server-1.8.0/
./upgrade/minor-upgrade.sh

Start Seafile Community Server

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

Now upgrade to version 1.3.0.

1. Shutdown Seafile server if it's running

cd haiwen/seafile-server-1.2.0
./seahub.sh stop
./seafile.sh stop

2. Run the upgrade script in seafile-server-1.3.0 directory.

cd haiwen/seafile-server-1.3.0
upgrade/upgrade_1.2_1.3_server.sh

3. Start the new server version as for any upgrade

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:

1. upgrade from 1.1.0 to 1.2.0;


2. upgrade from 1.2.0 to 1.3.0.

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.

Here is our dir strutcutre

haiwen
-- seafile-server-1.5.0
-- seafile-server-1.5.1
-- ccnet
-- seafile-data

1. Stop the current server first as for any upgrade

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

3. Start the new server version as for any upgrade

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.

sudo easy_install boto

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.

sudo easy_install boto

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
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.

seafile-machine# sudo scp user@ceph-admin-node:/etc/ceph/ /etc


Edit seafile configuration
Edit seafile-data/seafile.conf , add the following lines:

[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.

ceph-admin-node# rados mkpool seafile-blocks


ceph-admin-node# rados mkpool seafile-commits
ceph-admin-node# rados mkpool seafile-fs
Install and enable 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
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

You also have to add this user's keyring path to /etc/ceph/ceph.conf:

[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]

## must be "true" to enable office/pdf file online preview


enabled = true

## How many libreoffice worker process to run concurrenlty


workers = 1

## where to store the converted office/pdf files


outputdir = /tmp/

## how many pages are allowed to be previewed online. Default is 50 pages


max-pages = 50

## the max size of documents to allow to be previewed online, in MB. Default is 2 MB


max-size = 2

[SEAHUB EMAIL]

## must be "true" to enable user email notifications when there are new messages
enabled = true

## interval of sending seahub email. Can be s(seconds), m(minutes), h(hours), d(days)


interval = 30m

Options you may want to modify

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

The full text search of office/pdf documents is not enabled by


default. This is because it may consume quite some space for
INDEX FILES index_office_pdf false the search index. To turn it on, set this value to "true" and
recreate the search index. See the [[FAQ For Seafile
Professional Server]] for detail.

The max file size allowed to be previewed online is 2MB. The


OFFICE preview is converted office/pdf to HTML and display it in the
max-size 2MB
CONVERTER browser. If the file size is too large, the conversion may take too
long time and consume much space

When previewing a office/pdf document online, the pages


OFFICE displayed is the first 50 pages. If the value is too large, the
max-pages 50
CONVERTER conversion may take too long time and consume much space.

In the file /data/haiwen/seahub_settings.py :


# Enable add users as guests or not, defaults to ``False``. Guests are only able to use libraries shared to him/her.
ENABLE_GUEST = True

# Force user input strong password or not, defaults to ``False``.


USER_STRONG_PASSWORD_REQUIRED = True

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

You need to restart seahub so that your changes take effect.


If your changes don't take effect, You may need to delete 'seahub_setting.pyc'. (A cache file)

./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.

This feature is added since Seafile Professional Server 2.0.5 .


Notes
Your ES cluster must have thrift transport plugin installed. If not, install it:

bin/plugin -install elasticsearch/elasticsearch-transport-thrift/1.6.0

Restart your ES server after this.

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

es_host : The ip address of your ES server


es_port : The listening port of the Thrift transport module. By default it should be 9500
Details about File Search

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

# Set search language.


lang = german

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

I can't search Office/PDF files

First, make sure you have index_office_pdf = true in the file seafevents.conf:

[INDEX FILES]
...
index_office_pdf = true

Second, check whether the program pdftotext has been installed.

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:

sudo apt-get install poppler-utils

After installed pdftotext, you need to re-build your search index:

./pro/pro.py search --clear


./pro/pro.py search --update

I get no result when I search a keyword

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.

To be able to search immediately,

Make sure you have started seafile server


Update the search index manually:

cd haiwen/seafile-pro-server-2.0.4
./pro/pro.py search --update

Encrypted files cannot be searched

This is because the server can't index encrypted files, since, they are encrypted.

Handle your language more gracefully

Note: Added in seafile pro server 3.0.3.

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:

./pro/pro.py search --clear


./pro/pro.py search --update

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

At least 2 Linux server with at least 2GB RAM.

Install Python libraries

On each mode, you need to install some python libraries.

First make sure your have installed python 2.6 or 2.7, then:

sudo easy_install pip


sudo pip install boto

If you receive an error about "Wheel installs require setuptools >= ...", run this between the pip and boto lines above

sudo pip install setuptools --no-use-wheel --upgrade

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.

Get the license

Put the license you get under the top level diretory. In our wiki, we use the diretory /data/haiwen/ as the top level directory.

Download/Uncompress Seafile Professional Server

tar xf seafile-pro-server_2.1.3_x86-64.tar.gz

Now you have:

haiwen
├── seafile-license.txt
└── seafile-pro-server-2.1.3/

Setup Seafile Config

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

You have to add the following configuration to 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

Add following to pro-data/seafevents.conf to disable file indexing service:

[INDEX FILES]
external_es_server = true

Update Seahub Database

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

Backend Storage Settings

You also need to add the settings for backend cloud storage systems to the config files.

For NFS: Setup Seafile cluster with NFS


For S3: Setup With Amazon S3
For OpenStack Swift: Setup With OpenStackSwift
For Ceph: Setup With Ceph

Run and Test the Single Node

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.

Copy the config to all Seafile servers

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.

On each node, run ./seafile.sh and ./seahub.sh to start seafile server.


Setup Nginx/Apache and Https
You'll usually want to use Nginx/Apache and https for web access. You need to set it up on each machine running Seafile
server. Make sure the certificate on all the servers are the same.

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.

AWS Elastic Load Balancer (ELB)

In the AWS ELB management console, after you've added the Seafile server instances to the instance list, you should do
two more configurations.

First you should setup TCP listeners

Then you setup health check

HAProxy

This is a sample /etc/haproxy/haproxy.cfg :

(Assume your health check port is 12345 )

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

listen seahub 0.0.0.0:80


mode http
option httplog
option dontlognull
option forwardfor
server seahubserver01 192.168.1.165:80 check port 11001
server seahubserver02 192.168.1.200:80 check port 11001

listen seahub-https 0.0.0.0:443


mode tcp
option tcplog
option dontlognull
server seahubserver01 192.168.1.165:443 check port 11001
server seahubserver02 192.168.1.200:443 check port 11001

listen ccnetserver :10001


mode tcp
option tcplog
balance leastconn
server seafserver01 192.168.1.165:10001 check port 11001
server seafserver02 192.168.1.200:10001 check port 11001

listen seafserver :12001


mode tcp
option tcplog
balance leastconn
server seafserver01 192.168.1.165:12001 check port 11001
server seafserver02 192.168.1.200:12001 check port 11001
See how it runs
Now you should be able to test your cluster. Open https://seafile.example.com in your browser and enjoy. You can also
sync file with Seafile clients.

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:

indexing files for search


email notification

You need to choose one node to run the background tasks.

Let's assume you have three nodes in your cluster, namely A, B, and C, and you decide that:

Node A would run the background tasks


Node B and Node C are normal nodes
Configuring Node A (the background-tasks node)
On this node, you need:

Install Java

On Ubuntu/Debian:

sudo apt-get install default-jre

On CentOS/Red Hat:

sudo yum install java-1.6.0-openjdk

Edit pro-data/seafevents.conf

REMOVE the line:

external_es_server = true

Edit the firewall rules

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:

Edit pro-data/seafevents.conf, add the following lines:

[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:

./seafile-background-tasks.sh { start | stop | restart }


Setup Seafile cluster with NFS
In a Seafile cluster, one common way to share data among the Seafile server instances is to us NFS. You should only
share the files objects on NFS. Here we'll provide a tutorial about how and what to share.

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:

Move the seafile-data folder to /seafile-nfs :

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

FAQ about Search


However I tried, files in an encrypted library aren't listed in the search results

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.

To be able to search immediately,

Make sure you have started seafile server


Update the search index manually:

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.

In this case, you need to:

1. Edit the value of index_office_pdf option in /data/haiwen/pro-data/seafevents.conf to true

2. Restart seafile server

cd /data/haiwen/seafile-pro-server-1.7.0/
./seafile.sh restart

3. Delete the existing search index

./pro/pro.py search --clear

4. Create and update the search index again

./pro/pro.py search --update


FAQ about Office/PDF document preview
Document preview doesn't work, where to find more information?

You can check the log at logs/seafevents.log

How can I change max size and max pages of documents that can be previewed online ?

1. Locate the OFFICE CONVERTER section in /data/haiwen/pro-data/seafevents.conf .


2. Append following lines to the section

# the max size of documents to allow to be previewed online, in MB. Default is 2 MB


max-size = 2
# how many pages are allowed to be previewed online. Default is 50 pages
max-pages = 50

Then, restart seafile server

cd /data/haiwen/seafile-pro-server-1.7.0/
./seafile.sh restart
./seahub.sh restart

Document preview doesn't work on my Ubuntu/Debian server, what can I do?

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:

Remove the installed libreoffice:

sudo apt-get remove libreoffice* python-uno python3-uno

Download libreoffice packages from libreoffice official site

Install the downloaded pacakges:

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

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

2.2 License Provisions


Subject to the receipt by Seafile, Inc of the applicable license fees, You have the right use the Software as follows:

* 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

12. UPDATES AND SUPPORT


Seafile, Inc has the right, but no obligation, to periodically update the Software, at its complete discretion, without the consent or obligation to You or

13. TAXES AND OTHER CHARGES


You are responsible for paying all sales, use, excise valuated or other taxes or governmental charges in addition to freight, insurance and installation

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

Download and Setup Seafile Windows Professional Server


Migrate from Seafile Community Server
Seafile WebDAV Server

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:

1. This command should print the version of your java installation:

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.

Download elasticsearch server here.

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

Start the elasticsearch service

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.

You should have:

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:

1. This command should print the version of your java installation:

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.

Download elasticsearch server here.

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

Start the elasticsearch service

D:\elasticsearch\bin\service.bat start

Download the Seafile Server Package

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

Prepare the License File

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

Before you 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.

The migration script would do the following for you:

ensure your have all the prerequisites met


create necessary extra configurations
create extra database tables

Start Seafile Professional Server

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:

stop Seafile Professional Server if it's running


start the community server
Seafile WebDAV Server
Make sure you have Download and Setup Seafile Windows Professional Server
SeafDAV Configuration
Assume that:

you have uncompressed seafile windows server to C:/SeafileProgram/seafile-pro-server-2.1.4

you have chosen drive D:/ during seafile server initialization

The configuration file for WebDAV is D:/seafile-server/pro-data/seafdav.conf

[WEBDAV]

# Default is false. Change it to true to enable SeafDAV server.


enabled = true

port = 8080

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


fastcgi = false

# If you deploy seafdav behind nginx/apache, you need to modify "share_name".


share_name = /

Every time the configuration is modified, you need to restart seafile server to make it take effect.

Sample Configuration 1: No nginx/apache

Your WebDAV client would visit the Seafile WebDAV server at http://example.com:8080

[WEBDAV]
enabled = true
port = 8080
fastcgi = false
share_name = /

Sample Configuration 2: With nginx/apache

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

The corresponding Nginx configuration is (without https):


location /seafdav {
fastcgi_pass 127.0.0.1:8080;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_script_name;

fastcgi_param SERVER_PROTOCOL $server_protocol;


fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;

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 )

FastCGIExternalServer "YourDocumentRoot/seafdav.fcgi" -host 127.0.0.1:8000

Second, modify Apache config file httpd-vhosts.conf

<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

sudo apt-get install davfs2


sudo mount -t davfs -o uid= https://example.com/seafdav /media/seafdav/

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

Clients can't connect to seafdav sersver

By default, seafdav is disabled. Check whether you have enabled = true in seafdav.conf . If not, modify it and restart seafile
server.

The client gets "Error: 404 Not Found"

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

# interval of sending seahub email. Can be s(seconds), m(minutes), h(hours), d(days)


interval = 30m
Server Configuration and Customization

Config Files
This section explains how to change various config options for Seafile server.

There are three config files in the community edition:

ccnet/ccnet.conf: contains the network settings


seafile-data/seafile.conf: contains settings for seafile daemon and fileserver.
seahub_settings.py: contains settings for Seahub

There is one additional config file in the pro edition:

pro-data/seafevents.conf : contains settings for search and documents preview


Config Items
Email:

Sending email notifications


Customize email notifications

User management

User management options

User quota and download/upload size limits

User quota and download/upload size limits options


Customize Web
Customize web inferface
Seafile Network Configurations (ccnet.conf)
You may change Seafile's network options by modifying ccnet/ccnet.conf file. Let's walk through the options by an
example.

[General]

# This option is not used by Seafile server


USER_NAME=example

# Please don't change this ID.


ID=eb812fd276432eff33bcdde7506f896eb4769da0

# This is the name of this Seafile server. Currenlty it is only used in Seafile client's log.
NAME=example

# This is outside URL for Seahub(Seafile Web).


# The domain part (i.e., www.example.com) will be used in generating share links and download/upload file via web.
# Note: Outside URL means "if you use Nginx, it should be the Nginx's address"
SERVICE_URL=http://www.example.com:8000

[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

Storage Quota Setting (seafile.conf)


You may set a default quota (e.g. 2GB) for all users. To do this, just add the following lines to seafile-data/seafile.conf file

[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

Change upload/download settings.

[fileserver]
# Set maximum upload file size to 200M.
max_upload_size=200

# Set maximum download directory size to 200M.


max_download_dir_size=200

Note: You need to restart seafile and seahub so that your changes take effect.

./seahub.sh restart
./seafile.sh restart
Seahub Settings

Sending Email Notifications on Seahub


A few features work better if it can send email notifications, such as notifying users about new messages. If you want to
setup email notifications, please add the following lines to seahub_settings.py (and set your email server).

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

If you are using Gmail as email server, use following lines:

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 .

# Choices can be found here:


# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
# If running in a Windows environment this must be set to the same as your
# system time zone.
TIME_ZONE = 'UTC'

# Set this to seahub website's URL. This URL is contained in email notifications.
SITE_BASE = 'http://www.example.com/'

# Set this to your website's name. This is contained in email notifications.


SITE_NAME = 'example.com'

# Set seahub website's title


SITE_TITLE = 'Seafile'

# 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

# Enalbe or disalbe registration on web. Default is `False`.


# NOTE: since version 1.4.
ENABLE_SIGNUP = False

# Activate or deactivate user when registration complete. Default is `True`.


# If set to `False`, new users need to be activated by admin in admin panel.
# NOTE: since version 1.8
ACTIVATE_AFTER_REGISTRATION = False

# 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

# Hide `Organization` tab.


# If you want your private seafile behave exactly like https://cloud.seafile.com/, you can set this flag.
CLOUD_MODE = True

# Online preview maximum file size, defaults to 30M.


FILE_PREVIEW_MAX_SIZE = 30 * 1024 * 1024

# Age of cookie, in seconds (default: 2 weeks).


SESSION_COOKIE_AGE = 60 * 60 * 24 * 7 * 2

# Whether to save the session data on every request.


SESSION_SAVE_EVERY_REQUEST = False

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

You need to restart seahub so that your changes take effect.


If your changes don't take effect, You may need to delete 'seahub_setting.pyc'. (A cache file)
./seahub.sh restart
Seahub customization

Customize Seahub Logo and Css


Assume that you are using version 2.1.0. Create a folder custom under seafile-server-2.1.0/seahub/media . Put all the
customization files here. The upgrade script will copy the folder to seafile-server-2.1.1/seahub/media when you upgrade to
version 2.1.1.

Customize Logo

1. Add your logo file to seahub/media/custom/

2. Overwrite LOGO_PATH in seahub_settings.py

LOGO_PATH = 'custom/mylogo.png'

3. Overwrite LOGO_URL in seahub_settings.py

LOGO_URL = 'http://your-seafile.com'

Customize Seahub CSS

1. Add your css file to seahub/media/custom/ , for example, custom.css

2. Overwrite BRANDING_CSS in seahub_settings.py

BRANDING_CSS = 'custom/custom.css'
Customize footer and other Seahub Pages
Note: Since version 2.1.

Create a foler templates under <seafile-install-path>/seahub-data/custom

Customize footer

1. Copy seahub/seahub/templates/footer.html to seahub-data/custom/templates .


2. Modify footer.html .

Customize Download page

1. Copy seahub/seahub/templates/download.html to seahub-data/custom/templates .


2. Modify download.html .

Customize Help page

1. Copy seahub/seahub/help/templates/help to seahub-data/custom/templates/help .


2. Modify pages under help .
Sending Email Notifications on Seahub

Options email sending


Please add the following lines to seahub_settings.py to enable Email sending.

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

If you are using Gmail as email server, use following lines:

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

Options for user management


Here we summarize options related to user management in seahub_settings.py

# Enalbe or disalbe registration on web. Default is `False`.


ENABLE_SIGNUP = False

# Activate or deactivate user when registration complete. Default is `True`.


# If set to `False`, new users need to be activated by admin in admin panel.
ACTIVATE_AFTER_REGISTRATION = False

# 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

# Attempt limit before showing a captcha when login.


LOGIN_ATTEMPT_LIMIT = 3

# Whether a user's session cookie expires when the Web browser is closed.
SESSION_EXPIRE_AT_BROWSER_CLOSE = False
Administration

Enter the admin panel

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

The location of log files

Backup and Recovery

Backup and recovery:

Backup and recovery

Recover corrupt files after server hard shutdown or system crash:

Seafile FSCK

You can run Seafile GC to remove unused files:

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.

Resetting User Password

Administrator can reset password for a user in "System Admin" page.

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.

Forgot Admin Account or Password?

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:

Ccnet Log: logs/ccnet.log


Seafile server: logs/seafile.log
FileServer: logs/http.log
Controller: logs/controller.log
Seahub:logs/seahub_django_request.log, logs/seahub.log
Overview
There are generally two parts of data to backup

Seafile library data


Databases

If you setup seafile server according to our manual, you should have a directory layout like:

haiwen # Replace the name with your organization name


--seafile-server-2.x.x # untar from seafile package
--seafile-data # seafile configuration and data (if you choose the default)
--seahub-data # seahub data
--ccnet # ccnet configuration and data
--seahub.db # sqlite3 database used by seahub
--seahub_settings.py # optional config file for seahub

All your library data is stored under the 'haiwen' directory.

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:

ccnet/PeerMgr/usermgr.db: contains user information


ccnet/GroupMgr/groupmgr.db: contains group information
seafile-data/seafile.db: contains library metadata
seahub.db: contains tables used by the web front end (seahub)

For MySQL, the databases are created by the administrator, so the names can be different from one deployment to
another. There are 3 databases:

ccnet-db: contains user and group information


seafile-db: contains library metadata
seahub.db: contains tables used by the web front end (seahub)
Backup steps
The backup is a three step procedure:

1. Optional: Stop Seafile server first if you're using SQLite as database.


2. Backup the databases;
3. Backup the seafile data directory;

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.

mysqldump -h [mysqlhost] -u[username] -p[password] --opt ccnet-db > /backup/databases/ccnet-db.sql.`date +"%Y-%m-%d-%H-%M-%S"`

mysqldump -h [mysqlhost] -u[username] -p[password] --opt seafile-db > /backup/databases/seafile-db.sql.`date +"%Y-%m-%d-%H-%M-%S"`

mysqldump -h [mysqlhost] -u[username] -p[password] --opt seahub-db > /backup/databases/seahub-db.sql.`date +"%Y-%m-%d-%H-%M-%S"`

SQLite

You need to stop Seafile server first before backing up SQLite database.

sqlite3 /data/haiwen/ccnet/GroupMgr/groupmgr.db .dump > /backup/databases/groupmgr.db.bak.`date +"%Y-%m-%d-%H-%M-%S"`

sqlite3 /data/haiwen/ccnet/PeerMgr/usermgr.db .dump > /backup/databases/usermgr.db.bak.`date +"%Y-%m-%d-%H-%M-%S"`

sqlite3 /data/haiwen/seafile-data/seafile.db .dump > /backup/databases/seafile.db.bak.`date +"%Y-%m-%d-%H-%M-%S"`

sqlite3 /data/haiwen/seahub.db .dump > /backup/databases/seahub.db.bak.`date +"%Y-%m-%d-%H-%M-%S"`

Backing up Seafile library data

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.

To directly copy the whole data directory,

cp -R /data/haiwen /backup/data/haiwen-`date +"%Y-%m-%d-%H-%M-%S"`


This produces a separate copy of the data directory each time. You can delete older backup copies after a new one is
completed.

If you have a lot of data, copying the whole data directory would take long. You can use rsync to do incremental backup.

rsync -az /data/haiwen /backup/data

This command backup the data directory to /backup/data/haiwen .

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.

Restore the databases

Now with the latest valid database backup files at hand, you can restore them.

MySQL

mysql -u[username] -p[password] ccnet-db < ccnet-db.sql.2013-10-19-16-00-05


mysql -u[username] -p[password] seafile-db < seafile-db.sql.2013-10-19-16-00-20
mysql -u[username] -p[password] seahub-db < seahub-db.sql.2013-10-19-16-01-05

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.

The seaf-fsck tool accepts the following arguments:

seaf-fsck [-c config_dir] [-d seafile_dir] [repo_id_1 [repo_id_2 ...]]

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

This will check and recover all libraries on the server.

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:

Different versions of a file may share some data blocks;


Different libraries may also share some data blocks.

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.

The GC program cleans up two types of unused blocks:

1. Blocks that no library references to;


2. If you set history length limit on some libraries, the out-dated blocks in those libraries will also be removed.

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

It will print a warning if any useful blocks are missing.

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

If you built seafile server from source, just run

seafserv-gc -c ../../ccnet -d ../../seafile-data

After the GC program terminates, you may also check whether it mistakenly removed any useful data blocks:

seafserv-gc -c ../../ccnet -d ../../seafile-data --verify

It will print a warning if any useful blocks are missing.

If you want to do sanity check before actually removing any data, you can use the --dry-run option

seafserv-gc -c ../../ccnet -d ../../seafile-data --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 --ignore-errors or -i option

seafserv-gc -c ../../ccnet -d ../../seafile-data --ignore-errors

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.

In the wiki below, we assume your seafile installation folder is /data/haiwen .


SeafDAV Configuration
The configuration file is /data/haiwen/conf/seafdav.conf . If it is not created already, you can just create the file.

[WEBDAV]

# Default is false. Change it to true to enable SeafDAV server.


enabled = true

port = 8080

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


fastcgi = false

# If you deploy seafdav behind nginx/apache, you need to modify "share_name".


share_name = /

Every time the configuration is modified, you need to restart seafile server to make it take effect.

./seafile.sh restart

Sample Configuration 1: No nginx/apache

Your WebDAV client would visit the Seafile WebDAV server at http://example.com:8080

[WEBDAV]
enabled = true
port = 8080
fastcgi = false
share_name = /

Sample Configuration 2: With Nginx/Apache

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 without HTTPS

The corresponding Nginx configuration is (without https):


location /seafdav {
fastcgi_pass 127.0.0.1:8080;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_script_name;

fastcgi_param SERVER_PROTOCOL $server_protocol;


fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;

access_log /var/log/nginx/seafdav.access.log;
error_log /var/log/nginx/seafdav.error.log;
}

Nginx with HTTPS

Nginx conf with https:

location /seafdav {
fastcgi_pass 127.0.0.1:8080;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_script_name;

fastcgi_param SERVER_PROTOCOL $server_protocol;


fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;

fastcgi_param HTTPS on;

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):

FastCGIExternalServer /var/www/seafdav.fcgi -host 127.0.0.1:8080

Note, /var/www/seafdav.fcgi is just a placeholder, you don't need to actually have this file in your system.

Second, modify Apache config file (site-enabled/000-default):

Apache without HTTPS

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

Apache with HTTPS

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

sudo apt-get install davfs2


sudo mount -t davfs -o uid= https://example.com/seafdav /media/seafdav/

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

Clients can't connect to seafdav sersver

By default, seafdav is disabled. Check whether you have enabled = true in seafdav.conf . If not, modify it and restart seafile
server.

The client gets "Error: 404 Not Found"

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:

Encrypted folders can't be accessed by seaf-fuse.


Currently the implementation is '''read-only''', which means you can't modify the files through the mounted folder.
One debian/centos systems, you need to be in the "fuse" group to have the permission to mount a FUSE folder.

How to start seaf-fuse

Assume we want to mount to /data/seafile-fuse .

Create the folder as the mount point

mkdir -p /data/seafile-fuse

Start seaf-fuse with the script

Note: Before start seaf-fuse, you should have started seafile server with ./seafile.sh start .

./seaf-fuse.sh start /data/seafile-fuse

Stop seaf-fuse

./seaf-fuse.sh stop

Contents of the mounted folder

The top level folder

Now you can list the content of /data/seafile-fuse .

$ ls -lhp /data/seafile-fuse

drwxr-xr-x 2 root root 4.0K Jan 1 1970 [email protected]/


drwxr-xr-x 2 root root 4.0K Jan 1 1970 [email protected]/
drwxr-xr-x 2 root root 4.0K Jan 1 1970 [email protected]/
drwxr-xr-x 2 root root 4.0K Jan 1 1970 [email protected]/
drwxr-xr-x 2 root root 4.0K Jan 1 1970 [email protected]/

The top level folder contains many subfolders, each of which corresponds to a user
The time stamp of files and folders is not preserved.

The folder for each user


$ ls -lhp /data/seafile-fuse/[email protected]

drwxr-xr-x 2 root root 924 Jan 1 1970 5403ac56-5552-4e31-a4f1-1de4eb889a5f_Photos/


drwxr-xr-x 2 root root 1.6K Jan 1 1970 a09ab9fc-7bd0-49f1-929d-6abeb8491397_My Notes/

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}'''.

The folder for a library

$ ls -lhp /data/seafile-fuse/[email protected]/5403ac56-5552-4e31-a4f1-1de4eb889a5f_Photos/

-rw-r--r-- 1 root root 501K Jan 1 1970 image.png


-rw-r--r-- 1 root root 501K Jan 1 1970 sample.jpng

If you get a "Permission denied" error

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:

Add yourself to the fuse group

sudo usermod -a -G fuse

Logout your shell and login again

Now try ./seaf-fuse.sh start <path> again.


Security and auditing

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:

access.log: under directory logs/stats-logs

login log: in the web interface


traffic log: in the web interface
public link list: in the web interface
access.log
access.log (under directory logs/stats-logs) records the following information

file download via web


file download via API

The format is:

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.

2014-09-15 14:16:31,798 - file-download-api [email protected] 127.0.0.1 "curl/7.27.0" dfe1aa6a-9948-4c4c-9bf2-e67b2913199a "gc" "/unp.txt"


Develop Documents
How to Build Seafile

How to Setup Develop Envirnoment

Seafile Code Standard

Seafile Open API

Seafile Web API


Seafile Python API

Seafile Implement Detail

Seafile Data Model


Seafile Server Components
Seafile Sync algorithm
How to Build Seafile
You can build Seafile from our source code package or from the Github repo directly.

Client

Linux
Max OS X

Server

Build Seafile server


Linux

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

First you should get the latest source of libsearpc/ccnet/seafile/seafile-client:

Download the source tarball of the latest tag from

https://github.com/haiwen/libsearpc/tags (use v3.0-latest)


https://github.com/haiwen/ccnet/tags
https://github.com/haiwen/seafile/tags
https://github.com/haiwen/seafile-client/tags

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

Now uncompress them:

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

you can now start the client with $PREFIX/bin/seafile-applet.sh .


FreeBSD

Preparation

support for FreeBSD is still under construction.

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

#portmaster 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 devel/py-simplejson archivers/libarchive

For a fresh PkgNG users,

#pkg install autoconf automake intltool gsed libtool libevent2 curl \


glib20 ossp-uuid sqlite3 jansson vala cmake py-simplejson libarchive

Building

First you should get the latest source of libsearpc/ccnet/seafile/seafile-client:

Download the source tarball of the latest tag from

https://github.com/haiwen/libsearpc/tags (use v3.0-latest)


https://github.com/haiwen/ccnet/tags
https://github.com/haiwen/seafile/tags
https://github.com/haiwen/seafile-client/tags

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

Now uncompress them:

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

ln -sfh ../libdata/pkgconfig /usr/local/lib/pkgconfig

libsearpc

cd libsearpc-${version}
./autogen.sh
./configure --prefix=$PREFIX
make
sudo make install

ccnet

export CFLAGS="-I/usr/local/include/ossp/uuid -I/usr/local/include/event2"


export LDFLAGS="-L/usr/local/lib -L/usr/local/lib/event2"
cd ccnet-${version}
./autogen.sh
./configure --prefix=$PREFIX
make
sudo make install

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

cat >$PREFIX/bin/seafile-applet.sh <<END


#!/bin/bash
exec seafile-applet $@
END
cat >$PREFIX/bin/seaf-cli.sh <<END
export PYTHONPATH=/usr/local/lib/python2.7/site-packages
exec seaf-cli $@
END
chmod +x $PREFIX/bin/seafile-applet.sh $PREFIX/bin/seaf-cli.sh

you can now start the client with $PREFIX/bin/seafile-applet.sh .


Windows
Mac OS X

Setup homebrew environment


1. Install xcode

Download Xcode from website or App Store


Xcode Command Line Utilities might be sufficient to build seafile, but it is left untested yet.
2. Install homebrew

Make sure you don't have macports installed or uninstalled completely


Execute this from Terminal ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"

Then install seafile from homebrew

brew tap homebrew/dupes


brew tap Chilledheart/seafile
brew install libsearpc
brew install ccnet
brew install seafile --HEAD
brew install seafile-client --HEAD

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

Download Xcode from website or App Store


2. Install macports

Visit macports website


3. Install following libraries and tools using port

sudo port install autoconf intltool automake pkgconfig libtool glib2 \


ossp-uuid libevent vala openssl git qt4-mac python27 jansson gsed

4. Install python

sudo port select --set python python27


sudo port install py27-pip

5. Set pkg config environment

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

Generate xcode project from qmake

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.

4. Go to seafile-applet.app and see if it can run correctly.


Problem you may encounter
1. If install_name_tool reports "malformed object" "unknown load command", It may be the version of xcode command
line tools incompatible with install_name_tool .
2. If xcode can't find glib, Corrects xcode's "build settings/search paths/header search".
Server

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.

libevent-dev (2.0 or later )


libcurl4-openssl-dev (1.0.0 or later)
libglib2.0-dev (2.28 or later)
uuid-dev
intltool (0.40 or later)
libsqlite3-dev (3.7 or later)
libmysqlclient-dev (5.5 or later)
libarchive-dev
libtool
libjansson-dev
valac
libfuse-dev

The following libraries need to be compiled from source.

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:

[https://www.djangoproject.com/download/1.5.2/tarball/ django 1.5]


[https://github.com/djblets/djblets/tarball/release-0.6.14 djblets]
sqlite3
simplejson (python-simplejson)
PIL (aka. python imaging library, python-image)
chardet
gunicorn

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.

Prepare the directory layout

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:

Follow our instructions step by step


Make sure your directory layout is exactly the same with the guide in each step.

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

The currently layout is:

haiwen/
└── seafile-server

Get the source

First you should get the latest source of libsearpc/ccnet/seafile/seahub

Download the source tarball of the latest tag from

[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

Create a folder haiwen/src , and uncompress libsearpc/ccnet/seafile source to it.

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

And uncompress seahub tarball to haiwen/seafile-server :

cd haiwen/seafile-server
tar xf /path/to/seahub-2.0.3-server.tar.gz
mv seahub-2.0.3-server seahub

So far, The current directory layout is:

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

Components of the Seafile Server

The seafile server consists of the following components:

Process Name Functionality

ccnet-server underlying networking

seaf-server data management

Seahub website front-end of seafile server

fileserver handles raw file upload/download for Seahub

[[images/server-arch.png]]

'''ccnet''' stores its configuration and metadata is a directory named ccnet .


'''seaf-server''' store its configuration and data in a directory, normally named seafile-data .
'''seahub''' is written in Django. If you have any experience with Django, you should know the syncdb command must
be run to create all the database tables.
An '''admin account''' has to be created, so that you, the admin, can login with this account to manage the server.

These are the essential steps to create the configuration:

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

To create the configurations, you can either:

use the seafile-admin script(see below)


[[create server configuration by hand]]

Create Configurations with the seafile-admin script

seafile-admin should have been installed to system path after you have built and installed Seafile from source.

usage: seafile-admin [-h] {setup,start,stop,reset-admin} ...

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.

Name Usage Default Requirement

server The name of the server that would


3 ~ 15 letters or digits
name be shown on the client

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

ccnet port the tcp port used by ccnet 10001

seafile port tcp port used by seafile 12001

seafile
fileserver tcp port used by seafile fileserver 8082
port

admin Email address of the admin


email account

admin
password of the admin account
password

This is a screenshot of the '''seafile-admin setup''' command: [[images/seafile-admin-1.png]]

And a screenshot after setup is finished successfully: [[images/seafile-admin-2.png]]

At this time, the directory layout would be like this:

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

Start the Seafile Server

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''' ).

cd /data/haiwen # go to the top level directory


seafile-admin start

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]].

Stop the Seafile Server

To stop seafile server, run '''seafile-admin stop'''.

cd /data/haiwen # go to the top level directory


seafile-admin stop
Upgrade the Seafile Server
When you want to upgrade to a new vesrion of seafile server, you need to:

Stop the seafile server if it's running

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.

Get and compile the latest libsearpc/ccnet/seafile

See the '''Building''' section above.

Get the new seahub tarball and uncompress it

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

copy the scripts/upgrade/ subdir outside

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 (like from 1.1 to 1.2)

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

Non-continous version upgrade(like from 1.1 to 1.3)

If you upgrade a few versions at once, e.g. from 1.1.0 to 1.3.0. The procedure is:

upgrade from 1.1.0 to 1.2.0


upgrade from 1.2.0 to 1.3.0

Just run the upgrade scripts in sequence.


Minor Upgrade (like from 1.3.0 to 1.3.1)

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.

libevent-dev (2.0 or later )


libcurl4-openssl-dev (1.0.0 or later)
libglib2.0-dev (2.28 or later)
uuid-dev
intltool (0.40 or later)
libsqlite3-dev (3.7 or later)
libmysqlclient-dev (5.5 or later)
libarchive-dev
libtool
libjansson-dev
valac
libfuse-dev
python-dateutil

The following libraries need to be compiled from source.

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).

Complie libsearpc with

cd ~/dev/libsearpc
./autogen.sh
./configure
make
make install

Compile ccnet with

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

Compile seafile with

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

Or you can start ccnet, seafile and fileserver manually by:

ccnet-server -c ~/dev/seafile/test/basic/conf2/ -D all -f -


seaf-server -c ~/dev/seafile/test/basic/conf2/ -d ~/dev/seafile/test/basic/conf2/seafile-data/ -f -l -
fileserver -c ~/dev/seafile/test/basic/conf2/ -d ~/dev/seafile/test/basic/conf2/seafile-data/ -f
Prepare seahub
Go to seahub

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

Create admin account (assume seafile is under ~/dev/seafile)

python tools/seahub-admin.py ~/dev/seafile/tests/basic/conf2

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

Use only spaces, and indent 4 spaces at a time.

Inline

Define functions inline only when they are sufficiently small.

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

Get Upload Blocks Link


Get Update Blocks Link

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

List Group And Contacts


Get File Activities
Seafile Web API V2

API Basics
All API calls must be authenticated with a valid Seafile API key.

curl -H 'Authorization: Token 24fd3c026886e3121b2ca630805ed425c272cb96' https://cloud.seafile.com/api2/auth/ping/

The api key can be retrieved by the obtain auth api. See the Quick Start for details.

For each API, we provide curl examples to illustrate the usage.


Status Code
200: OK
201: CREATED
202: ACCEPTED
301: MOVED_PERMANENTLY
400: BAD_REQUEST
403: FORBIDDEN
404: NOT_FOUND
409: CONFLICT
429: TOO_MANY_REQUESTS
440: REPO_PASSWD_REQUIRED
441: REPO_PASSWD_MAGIC_REQUIRED
500: INTERNAL_SERVER_ERROR
520: OPERATION_FAILED
Quick Start
ping

curl https://cloud.seafile.com/api2/ping/

"pong"

obtain auth token

curl -d "[email protected]&password=123456" https://cloud.seafile.com/api2/auth-token/

{"token": "24fd3c026886e3121b2ca630805ed425c272cb96"}

auth ping

curl -H 'Authorization: Token 24fd3c026886e3121b2ca630805ed425c272cb96' https://cloud.seafile.com/api2/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')

To retrieve all users, just set both start and limit to -1 .

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

curl -H "Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd" -H 'Accept: application/json; indent=4' https://cloud.seafile.com/api2/accou

Sample response

[
{
"email": "[email protected]"
},
{
"email": "[email protected]"
}
]

Errors

403 Permission error, only administrator can perform this action

Check Account Info

GET https://cloud.seafile.com/api2/account/info/

Sample request

curl -H "Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd" -H 'Accept: application/json; indent=4' https://cloud.seafile.com/api2/accou

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

403 Permission error, only administrator can perform this action

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

curl -v -X PUT -d "password=654321&is_staff=true" -H "Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd" -H 'Accept: application/json;

Sample response
...
< HTTP/1.0 200 OK
...

"success"

Success

Response code 200(OK) is returned.

Errors

400 Bad Request, keyword password is required


403 Permission error, only administrator can perform this action

Delete Account

DELETE https://cloud.seafile.com/api2/accounts/{email}/

Sample request

curl -v -X DELETE -H "Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd" -H 'Accept: application/json; indent=4' https://cloud.seafile.co

Sample response

"success"

Errors

403 Permission error, only administrator can perform this action


Starred Files

List starred files

GET https://cloud.seafile.com/api2/starredfiles/

Sample request

curl -H "Authorization: Token f2210dacd9c6ccb8133606d94ff8e6199b477fd" -H 'Accept: application/json; indent=4' https://cloud.seafile.com/api2/starred

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

curl -v -d "repo_id=dae8cecc-2359-4d33-aa42-01b7846c4b32&p=/foo.md" -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' -H 'Ac

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

Response code is 200(OK), and a string named "success" is returned.

Errors

400 repo_id or p is missing, or p is not valid file path(e.g. /foo/bar/).


User Messages

List User Messages

GET https://cloud.seafile.com/api2/user/msgs/{id_or_email}/

Request parameters

id_or_email

Sample request

curl -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' "https://cloud.seafile.com/api2/user/msgs/2/"

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

404 user not found

Reply A User Message

POST https://cloud.seafile.com/api2/user/msgs/{id_or_email}/

Request parameters

id_or_email
message

Sample request

curl -d "message=this is a user msg reply" -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' "https://cloud.seafile.com/api2/user/


Sample response

{
"msgid": 4
}

Errors

404 user not found

Count Unseen Messages

GET https://cloud.seafile.com/api2/unseen_messages/

Sample request

curl -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' "https://cloud.seafile.com/api2/unseen_messages/"

Sample response

{
"count": 1
}
Group

List Groups

GET https://cloud.seafile.com/api2/groups/

Sample request

curl -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' "https://cloud.seafile.com/api2/groups/"

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

curl -X PUT -d "group_name=newgroup" -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' "https://cloud.seafile.com/api2/groups/"

Sample response

{"group_id": 3, "success": true}

Errors

400 There is already a group with that name.

Delete Group

DELETE https://cloud.seafile.com/api2/groups/{group_id}/
Request parameters

None

Sample request

curl -X DELETE -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' "https://cloud.seafile.com/api2/groups/1/"

Success

200 if everything is fine.

Errors

400 if ad group id format


404 if Group not found
403 if Forbid to delete group
520 if Failed to remove group (generic error)

Rename Group

POST https://cloud.seafile.com/api2/groups/{group_id}/

Request parameters

operation (value must be 'rename')


newname (the new name for the group)

Sample request

curl -d "operation=rename&newname=pinkfloyd_lovers" -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' "https://cloud.seafile.c

Success

200 if everything is fine.

Errors

404 if Group not found


403 if Forbid to rename group
400 if Newname is missing or if Group name is not valid of if There is already a group with that name or Operation
can only be rename.

Group Member

Add A 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

400 invalid group id


403 only administrators can add group members
404 unable to find group

Delete A Group Member

DELETE https://cloud.seafile.com/api2/groups/{group_id}/members/

Request parameters

user_name

Sample request

curl -X DELETE -d "[email protected]" -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' "https://cloud.seafile.com/a

Sample response

{"success": true}

Errors

400 invalid group id


403 only administrators can remove group members
404 unable to find group

Group Message

Get Group Messages

GET https://cloud.seafile.com/api2/group/msgs/{group_id}/

Request parameters

group_id

Sample request

curl -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' "https://cloud.seafile.com/api2/group/msgs/1/"

Sample response
{
"next_page": -1,
"msgs": [
{
"reply_cnt": 0,
"timestamp": 1398230602,
"replies": [],
"from_email": "[email protected]",
"msgid": 1,
"msg": "test discuss",
"nickname": "user"
}
]
}

Get Group Message Detail

GET https://cloud.seafile.com/api2/group/{group_id}/msg/{msg_id}/

Request parameters

group_id
msg_id

Sample request

curl -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' "https://cloud.seafile.com/api2/group/1/msg/1/"

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

404 message not found

Send A Group Message

POST https://cloud.seafile.com/api2/group/msgs/{group_id}/

Request parameters
message
group_id
repo_id(optional)
path(optional)

Sample request

curl -d "message=this is another test&repo_id=c7436518-5f46-4296-97db-2fcba4c8c8db&path=/123.md" -H 'Authorization: Token f2210dacd9c6ccb813

Sample response

{
"msgid": 3
}

Reply A Group Message

POST https://cloud.seafile.com/api2/group/{group_id}/msg/{msg_id}

Request parameters

group_id
msg_id
message

Sample request

curl -d "message=this is a reply" -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' "https://cloud.seafile.com/api2/group/1/msg/1/

Sample response

{
"msgid": 3
}

Errors

404 message not found

Get Group Message Replies

GET https://cloud.seafile.com/api2/new_replies/

Sample request

curl -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' "https://cloud.seafile.com/api2/new_replies/"

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

File Share Link

List File Share Links

GET https://cloud.seafile.com/api2/shared-links/

Sample request

curl -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' "https://cloud.seafile.com/api2/shared-links/"

Sample response

{"fileshares": [{"username": "[email protected]", "repo_id": "a582d3bc-bcf5-421e-9125-741fa56d18d4", "ctime": null, "s_type": "d", "token": "e4108274

Create File Share Link

PUT https://cloud.seafile.com/api2/repos/{repo-id}/file/shared-link/

Request parameters

repo-id
type
p (Path to the file)

Sample request

Create download link for file

curl -v -X PUT -d "type=f&p=/foo.md" -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' -H 'Accept: application/json; indent=4' http

Create download link for directory

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 File Share Link

DELETE https://cloud.seafile.com/api2/shared-links/?t=0ae587a7d1

Request parameters

Sample request

curl -v -X DELETE -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' "https://cloud.seafile.com/api2/shared-links/?t=0ae587a7d1"

Sample response

...
< HTTP/1.0 200 OK
...

Shared Libraries

List Shared Libraries

GET https://cloud.seafile.com/api2/shared-repos/

Sample request

curl -v -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' -H 'Accept: application/json; indent=4' https://cloud.seafile.com/api2/sha

Sample response

[{"repo_id": "7d42522b-1f6f-465d-b9c9-879f8eed7c6c", "share_type": "personal", "permission": "rw", "encrypted": false, "user": "[email protected]", "la

List Be Shared Libraries

GET https://cloud.seafile.com/api2/beshared-repos/

Sample request

curl -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' "https://cloud.seafile.com/api2/beshared-repos/"

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

share_type ('personal', 'group' or 'public')


user (or users)
group_id
permission

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

curl -X PUT -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' "https://cloud.seafile.com/api2/shared-repos/7d42522b-1f6f-465d-b9c

Sample response

"success"

Unshare A Library

DELETE https://cloud.seafile.com/api2/shared-repos/{repo-id}/

Request parameters

share_type ('personal', 'group' or 'public')


user
group_id

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

curl -X DELETE -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' "https://cloud.seafile.com/api2/shared-repos/7d42522b-1f6f-465d

Sample response

"success"

Shared Files

List Shared Files

GET https://cloud.seafile.com/api2/shared-files/
Sample request

curl -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' "https://cloud.seafile.com/api2/shared-files/"

Sample response

{"priv_share_in": [{"s_type": "f", "repo_id": "989e3952-9d6f-4427-ab16-4bf9b53212eb", "permission": "r", "to_user": "[email protected]", "token": "94aa

Download Shared File

GET https://cloud.seafile.com/api2/f/{token}/

Request parameters

token(file share token)

Sample request

curl -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' "https://cloud.seafile.com/api2/f/ad93cd0d66/"

Sample response

"http://192.168.1.101:8082/files/89223601/lib.md"

Errors

404 repo/token/file not found


520 OPERATION FAILED, fail to get file id by path

Get Shared File Detail

GET https://cloud.seafile.com/api2/f/{token}/detail/

Request parameters

token(file share token)

Sample request

curl -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' "https://cloud.seafile.com/api2/f/ad93cd0d66/detail/"

Sample response

{"repo_id": "989e3952-9d6f-4427-ab16-4bf9b53212eb", "name": "lib.md", "mtime": 1398218747, "path": "/lib.md", "type": "file", "id": "000000000000000

Errors

404 repo/token/file not found


520 OPERATION FAILED, fail to get file id by path
Delete Shared File

DELETE https://cloud.seafile.com/api2/shared-files/?t=0ae587a7d1

Request parameters

Sample request

curl -v -X DELETE -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' "https://cloud.seafile.com/api2/shared-files/?t=94aace406a"

Sample response

...
< HTTP/1.0 200 OK
...

Download Private Shared File

GET https://cloud.seafile.com/api2/s/f/{token}/

Request parameters

token(private file share token)

Sample request

curl -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' "https://cloud.seafile.com/api2/s/f/c5aa5f0219/"

Sample response

"http://192.168.1.101:8082/files/6960d5a4/lib.md"

Errors

404 repo/token/file not found


520 OPERATION FAILED, fail to get file id by path

Get Private Shared File Detail

GET https://cloud.seafile.com/api2/s/f/{token}/detail/

Request parameters

token(private file share token)

Sample request

curl -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' "https://cloud.seafile.com/api2/s/f/c5aa5f0219/detail/"


Sample response

{"repo_id": "989e3952-9d6f-4427-ab16-4bf9b53212eb", "name": "lib.md", "shared_by": "[email protected]", "mtime": 1398218747, "path": "/lib.md", "t

Errors

404 repo/token/file not found


520 OPERATION FAILED, fail to get file id by path
Library

Library

Get Default Library

GET https://cloud.seafile.com/api2/default-repo/

Sample request

curl -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' "https://cloud.seafile.com/api2/default-repo/"

Sample response

{
"repo_id": "691b3e24-d05e-43cd-a9f2-6f32bd6b800e",
"exists": true
}

Create Default Library

POST https://cloud.seafile.com/api2/default-repo/

Sample request

curl -X POST -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' "https://cloud.seafile.com/api2/default-repo/"

Sample response

{
"repo_id": "691b3e24-d05e-43cd-a9f2-6f32bd6b800e",
"exists": true
}

List Libraries

GET https://cloud.seafile.com/api2/repos/

Sample request

curl -H 'Authorization: Token 24fd3c026886e3121b2ca630805ed425c272cb96' -H 'Accept: application/json; indent=4' https://cloud.seafile.com/api2/repo

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 Library Info

GET https://cloud.seafile.com/api2/repos/{repo-id}/

Request parameters

repo-id

Sample request

curl -G -H 'Authorization: Token 24fd3c026886e3121b2ca630805ed425c272cb96' -H 'Accept: application/json; indent=4' https://cloud.seafile.com/api2/re

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 Library Owner

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

403 Permission error, only administrator can perform this action

Get Library History

GET https://cloud.seafile.com/api2/repos/{repo-id}/history/

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

{"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

curl -v -d "name=foo&desc=new library" -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' -H 'Accept: application/json; indent=4'

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

400 Library name missing.


520 Operation failed.

Check/Create Sub Library

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

curl -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d9b477fd' -H 'Accept: application/json; indent=4' https://cloud.seafile.com/api2/repos/d

Sample response

{"sub_repo_id": "c0a3283c-013c-4a7c-8f68-006f06fa6dec"}

Errors

400 Argument missing


500 INTERNAL SERVER ERROR

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

400 Library does not exist.

403 Only library owner can perform this operation.

Decrypt Library

POST https://cloud.seafile.com/api2/repos/{repo-id}/

Request parameters

password

Sample request

curl -v -d "password=123" -H 'Authorization: Token e6a33d61954f219a96b60f635cf02717964e4385' -H 'Accept: application/json; indent=4' https://cloud.

Sample response

"success"

Errors

400 Incorrect password


409 Repo is not encrypt
500 Internal server error

Create Public Library

POST https://cloud.seafile.com/api2/repos/{repo-id}/public/

Request parameters

repo-id

Sample request

curl -X POST -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d9b477fd' -H 'Accept: application/json; indent=4' https://cloud.seafile.com/api2

Sample response

...
< HTTP/1.0 200 OK
...
Success

Response code is 200(OK), and a string "success" is returned.

Errors

404 Repo not found


403 Forbid to access this repo
500 INTERNAL SERVER ERROR, Unable to make repo public

Remove Public Library

DELETE https://cloud.seafile.com/api2/repos/{repo-id}/public/

Request parameters

repo-id

Sample request

curl -X DELETE -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d9b477fd' -H 'Accept: application/json; indent=4' https://cloud.seafile.com/ap

Sample response

...
< HTTP/1.0 200 OK
...

Success

Response code is 200(OK), and a string "success" is returned.

Errors

404 Repo not found


403 Forbid to access this repo
500 INTERNAL SERVER ERROR, Unable to remove public repo

Fetch library download info

GET https://cloud.seafile.com/api2/repos/{repo-id}/download-info/

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
{
"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]"
}

List Virtual Libraries

GET https://cloud.seafile.com/api2/virtual-repos/

Sample request

curl -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' "https://cloud.seafile.com/api2/virtual-repos/"

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

curl -G -H ‘Authorization: Token 24fd3c026886e3121b2ca630805ed425c272cb96’ -H ‘Accept: application/json; indent=4’ https://cloud.seafile.com/api2/s

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

404 Search not supported.


400 Missing argument q.

File

Download File

GET https://cloud.seafile.com/api2/repos/{repo-id}/file/?p=/foo

Request parameters

repo-id
p

Sample request

curl -v -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' -H 'Accept: application/json; charset=utf-8; indent=4' https://cloud.seafi

Sample response

"https://cloud.seafile.com:8082/files/adee6094/foo.c"

Errors

400 Path is missing


404 File not found
520 Operation failed.

Get File Detail


GET https://cloud.seafile.com/api2/repos/{repo-id}/file/detail/?p=/foo.c

repo-id
p

Sample request

curl -H 'Authorization: Token f2210dacd3606d94ff8e61d99b477fd' -H 'Accept: application/json; charset=utf-8; indent=4' https://cloud.seafile.com/api2/re

Sample response

{
"id": "013d3d38fed38b3e8e26b21bb3463eab6831194f",
"mtime": 1398148877,
"type": "file",
"name": "foo.py",
"size": 22
}

Errors

400 Path is missing


520 Operation failed.

Get File History

GET https://cloud.seafile.com/api2/repos/{repo-id}/file/history/?p=/foo.c

Request parameters

repo-id
p

Sample request

curl -H 'Authorization: Token f2210dacd3606d94ff8e61d99b477fd' -H 'Accept: application/json; charset=utf-8; indent=4' https://cloud.seafile.com/api2/re

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

400 Path is missing


404 File not found

Download File From a Revision

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

curl -H 'Authorization: Token f2210dacd3606d94ff8e61d99b477fd' -H 'Accept: application/json; charset=utf-8; indent=4' https://cloud.seafile.com/api2/re

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

curl -v -d "operation=create" -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' -H 'Accept: application/json; charset=utf-8; indent

Sample response

...
< HTTP/1.1 201 CREATED
...
"success"

Success

Response code is 201, and a string "success" is returned.

Errors

403 FORBIDDEN, You do not have permission to move file


520 OPERATION FAILED, fail to create file

Rename File

POST https://cloud.seafile.com/api2/repos/{repo-id}/file/?p=/foo.c

Request parameters

repo-id
p
operation
newname

Sample request

curl -v -d "operation=rename&newname=newfoo.c" -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' -H 'Accept: application/json

Sample response
...
< HTTP/1.1 301 MOVED PERMANENTLY
...
"success"

Success

Response code is 301, and a string "success" is returned.

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

curl -v -d "operation=move&dst_repo=affc837f-7fdd-4e91-b88a-32caf99897f2&dst_dir=/" -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d9

Sample response

...
< HTTP/1.1 301 MOVED PERMANENTLY
...
"success"

Success

Response code is 301, and a string "success" is returned.

Errors

400 BAD REQUEST, Path is missing or invalid(e.g. p=/)


403 FORBIDDEN, You do not have permission to move file
404 NOT FOUND, repo not found
500 INTERNAL SERVER ERROR

Copy File

POST https://cloud.seafile.com/api2/repos/{repo_id}/fileops/copy/
Request parameters

p: source folder path, defaults to "/"

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

curl -d "dst_repo=73ddb2b8-dda8-471b-b7a7-ca742b07483c&dst_dir=/&file_names=foo.c" -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61

Sample response

"success"

Errors

400 missing argument


403 You do not have permission to copy file
404 repo not found
502 failed to copy file

Revert File

PUT https://cloud.seafile.com/api2/repos/{repo_id}/file/revert/

Request parameters

repo_id
p
commit_id

Sample request

curl -v -X PUT -d "commit_id=a1ec20709675f4dc8db825cdbca296be245d189b&p=/foo.c" -H "Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d9

Sample response

...
< HTTP/1.0 200 OK
...

{"ret": 0}

Success

Response code 200(OK) is returned.

Errors

400 Path is missing


Delete File

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

400 Path is missing


520 Operation failed.

Note

This can also be used to delete directory.

Upload File
Get Upload Link

GET https://cloud.seafile.com/api2/repos/{repo-id}/upload-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

"http://cloud.seafile.com:8082/upload-api/ef881b22"

Errors

500 Run out of quota

Upload File
After getting the upload link, POST to this link for uploading files.

POST http://cloud.seafile.com:8082/upload-api/ef881b22

Errors

400 Bad request


440 Invalid filename
441 File already exists
500 Internal server error

Sample request

curl -H "Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd" -F [email protected] -F filename=test.txt -F parent_dir=/ http://cloud.seafile.co

Sample response

"adc83b19e793491b1c6ea0fd8b46cd9f32e592fc"

Note

For python client uploading, see https://cloud.seafile.com/f/1b0ade6edc/

Update file
Get Update Link

GET https://cloud.seafile.com/api2/repos/{repo-id}/update-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

"http://cloud.seafile.com:8082/update-api/ef881b22"

Errors

500 Run out of quota

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

curl -H "Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd" -F [email protected] -F filename=test.txt -F target_file=/test.txt http://cloud.se

Returns

The id of the updated file

Sample response

"adc83b19e793491b1c6ea0fd8b46cd9f32e592fc"

Errors

400 Bad request


440 Invalid filename
500 Internal server error

Get Upload Blocks Link

GET https://cloud.seafile.com/api2/repos/{repo-id}/upload-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/upload-blks-api/c1e6823d"

Errors

403 Can not access repo


520 above quota

Get Update Blocks Link

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

403 Can not access repo


520 above quota

Directory

List Directory Entries

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

curl -H "Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d9b477fd" -H 'Accept: application/json; indent=4' https://cloud.seafile.com/api2/repos/

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

404 The path is not exist.


440 Repo is encrypted, and password is not provided.
520 Operation failed..

Create New Directory

POST https://cloud.seafile.com/api2/repos/{repo-id}/dir/

repo-id
p
operation=mkdir (post)

Sample request

curl -d "operation=mkdir" -v -H 'Authorization: Tokacd9c6ccb8133606d94ff8e61d99b477fd' -H 'Accept: application/json; charset=utf-8; indent=4' https:

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

400 Path is missing or invalid(e.g. p=/)


520 Operation failed.

Notes

Newly created directory will be renamed if the name is duplicated.

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

curl -d "operation=rename&newname=pinkfloyd_newfolder" -v -H 'Authorization: Tokacd9c6ccb8133606d94ff8e61d99b477fd' -H 'Accept: application/jso

Success

Response code 200 if everything is ok

Errors

403 if You do not have permission to rename a folder


400 if newname is not given
520 if Failed to rename directory (generic problem)

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

Response code is 200(OK), and a string "success" is returned.

Errors

400 Path is missing or invalid(e.g. p=/)


520 Operation failed.

Note

This can also be used to delete file.

Download Directory

GET https://cloud.seafile.com/api2/repos/{repo-id}/dir/download/?p=/foo

repo-id
p

Sample request

curl -H 'Authorization: Token f2210dacd3606d94ff8e61d99b477fd' -H 'Accept: application/json; charset=utf-8; indent=4' https://cloud.seafile.com/api2/re

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

curl -v -X POST -d "[email protected]&s_type=d&path=/dir&perm=r" -H 'Authorization: Token f2210dacd3606d94ff8e61d99b477fd' -H 'Accept: a

Sample response

...
< HTTP/1.0 200 OK
...

Success

Response code is 200(OK).

Batch Delete

Pipelining over HTTP/1.1 can be used to delete multiple files and directories without losing performance.

A sample request looks like curl -X DELETE https://cloud.seafile.com/api2/repos/{repo-id}/dir/?p=/foo

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 User Avatar

GET https://cloud.seafile.com/api2/avatars/user/{user}/resized/{size}/

Request parameters

user
size

Sample request

curl -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' "https://cloud.seafile.com/api2/avatars/user/[email protected]/resized/80

Sample response

{
"url": "http://127.0.0.1:8000/media/avatars/default.png",
"is_default": true,
"mtime": 0
}

Get Group Avatar

GET https://cloud.seafile.com/api2/avatars/group/{group_id}/resized/{size}/

Request parameters

group_id
size

Sample request

curl -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' "https://cloud.seafile.com/api2/avatars/group/1/resized/80/

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

curl -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' "https://cloud.seafile.com/api2/groupandcontacts/"

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

curl -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' "https://cloud.seafile.com/api2/events/"

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.

Set Environment Variable

If you want use Seafile-API, set environment variable first. That's what seaf_migrate_3.sh does:

1. get ccnet/seafile config file path and export them;


2. export Python path;
3. call seaf_migrate_3.py .

Example code

#!/bin/bash

#get path of ccnet.conf


SCRIPT=$(readlink -f "$0") # haiwen/seafile-server-3.0.3/upgrade/seaf_migrate_3.sh
UPGRADE_DIR=$(dirname "$SCRIPT") # haiwen/seafile-server-3.0.3/upgrade/
INSTALLPATH=$(dirname "$UPGRADE_DIR") # haiwen/seafile-server-3.0.3/
TOPDIR=$(dirname "${INSTALLPATH}") # haiwen/
default_ccnet_conf_dir=${TOPDIR}/ccnet

#get path of seafile.conf


function read_seafile_data_dir () {
seafile_ini=${default_ccnet_conf_dir}/seafile.ini
if [[ ! -f ${seafile_ini} ]]; then
echo "${seafile_ini} not found. Now quit"
exit 1
fi
seafile_data_dir=$(cat "${seafile_ini}")
if [[ ! -d ${seafile_data_dir} ]]; then
echo "Your seafile server data directory \"${seafile_data_dir}\" is invalid or doesn't exits."
echo "Please check it first, or create this directory yourself."
echo ""
exit 1;
fi

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

Then seaf_migrate_3.py will call Seafile-API to copy library:

1. Get library ID from input.


2. Get origin_repo object.
3. Create a new library, set name, desc and owner.
4. Copy stuffs from old library to new library.

Example code

#!/usr/bin/env python

import os
import stat
import sys
from seaserv import seafile_api

def count_files_recursive(repo_id, path='/'):


num_files = 0
for e in seafile_api.list_dir_by_path(repo_id, path):
if stat.S_ISDIR(e.mode):
num_files += count_files_recursive(repo_id,
os.path.join(path, e.obj_name))
else:
num_files += 1
return num_files

#Get library ID from input


origin_repo_id = sys.argv[1]

#Get origin_repo object


origin_repo = seafile_api.get_repo(origin_repo_id)
username = seafile_api.get_repo_owner(origin_repo_id)

#Create a new library, set name, desc and owner


new_repo_id = seafile_api.create_repo(name=origin_repo.name,
desc=origin_repo.desc,
username=username, passwd=None)

#Copy stuffs from old library to new library


dirents = seafile_api.list_dir_by_path(origin_repo_id, '/')
for e in dirents:
print "copying: " + e.obj_name
obj_name = e.obj_name
seafile_api.copy_file(origin_repo_id, '/', obj_name, new_repo_id, '/',
obj_name, username, 0, 1)

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.

foo@foo:~/haiwen/seafile-server-3.0.3/upgrade$ ./seaf_migrate_test.sh c8bbb088-cbaf-411d-8bd8-9870763f0e5f


Loading ccnet config from /home/foo/haiwen/ccnet
Loading seafile config from /home/foo/haiwen/seafile-data
copying: test.html
copying: test-dir-2
copying: test-dir
copying: solar.html
copying: examples.desktop
************************************************************
OK, verifying...
Origin library(c8bbb088): 10 files. New Library(4d6f4837): 10 files.
************************************************************
List Of Seafile-API
This list is based on seafile-server-3.0.3, and parameter was omitted.

For more infomation about Seafile-API, please see api.py.

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

Object represents a file.


Block
A file is further divided into blocks with variable lengths. We use Content Defined Chunking algorithm to divide file into
blocks. A clear overview of this algorithm can be found at http://pdos.csail.mit.edu/papers/lbfs:sosp01/lbfs.pdf. On
average, a block's size is around 1MB.

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".

A typical synchronization work flow consists of the following steps:

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

You might also like