Seafile Server - Private Cloud

Requirement:
All you need is a Linux Ubuntu (Debian) home server and a little Linux configuration knowledge.

If you use Dropbox you will immediately understand how to use a Seafile.
Advantage of Seafile over Dropbox: your data will be stored inside your personal home-server and more functionality with Seafile, e.g. group working

Download Seafile
Deploying and Directory Layout
Seafile Server Set-up
Running Seafile Server

Setup Port Forwarding Rules

Download the latest server package.
#check if your system is x86 (32bit) or x86_64 (64 bit)
uname -m

#download for 32bit
wget http://seafile.googlecode.com/files/seafile-server_{version}_i386.tar.gz

#or for 64bit
wget http://seafile.googlecode.com/files/seafile-server_{version}_x86-64.tar.gz

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

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 or 2.7
- python-setuptools
- python-simplejson
- python-imaging
- sqlite3
#on Ubuntu
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.


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.4.0 directory, run the following commands
Start seafile:
./seafile.sh start # Start seafile service
Start seahub:
./seahub.sh start <port> # Start seahub website, port defaults to 8000
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 (1) stop the seafile server
./seahub.sh stop
./seafile.sh stop

(2) 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

and (3) restart seafile server
./seafile.sh start
./seahub.sh start 8001

seeSeafile 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

___________________________________________________

Setup Autostart on boot
On Ubuntu/Debain, 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 script_path accordingly)

#!/bin/sh
# 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-2.0.4
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
Create a file /etc/init/seafile-server.conf

start on (started mysql
and runlevel [2345])
stop on (stopping mysql
and 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

sudo ln -s /etc/init.d/seafile-server /etc/rc0.d/K12seafileserver
sudo ln -s /etc/init.d/seafile-server /etc/rc2.d/S12seafileserver

reboot

After reboot your Seafile server is automatically starts.

Setup Port Forwarding Rules

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

  • ccnet 10001
  • seaf-server 12001
  • httpserver 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.

Note:
If you are behind a restricted firewall, for eg workplace / office intranet and would like to use Seafile the following should be done:
install: putty
Create a SSH connection profile to your Seafile server with port forwards inside the tunnel.
It is under: Connection, SSH, Tunnels
Add the above 4 ports to the profile and save it.

Load the saved profile and login to your Seafile server.
Add a new account to your Windows Seafile client.
Here the servername: localhost:8000
User and password are the same as normally used for your Seafile server.
Click on connect, and now you should be able to reach your Seafile server inside a SSH secured tunnel.

Admin