How to Setup Seafile File Storage Server on Ubuntu 16.04

Seafile storage server is an open-source cloud-based file storage system similar to Dropbox. Seafile can be deployed on a client’s own system and  this feature provides a stronger security as the passwords are only interchanged between the client who setup the system and his / her own users rather than a cloud hosting organization. This article we cover how install and setup  Seafile file storage server on Ubuntu 16.04.

1. Prerequisites

You must have already setup basic LAMP Server on your Ubuntu 16.04 and make sure that its services are working fine. If you have not setup LAMP server, then quickly setup LAMP server using tasksel. Use the following command to install tasksel followed by LAMP server.

root@demohost:~# sudo apt-get install tasksel

Execute tasksel from the shell and then select LAMP server from the list and press 'Ok'

root@demohost:~# tasksel

You will be prompted to provide a root password for MySQL. Once the installation of LAMP server is complete, check the status of apache, MySQL and version of PHP.

root@demohost:~# service apache2 status

root@demohost:~# service mysql status

root@demohost:~# php -v

Seafile storage setup requires few python modules that must be installed beforehand, otherwise installation setup will not proceed. we will  install the required python modules by using apt-get.

root@demohost:~# apt-get install sqlite python-simplejson python-setuptools python-imaging python-mysqldb

2. Download Seafile Storage Server Package

Create seafile configuration directories and download seafile storage server package from the official seafile download Page where you will find its cross platform packages. We will download generic linux 64-bit package as shown below.

Once you have copied the link location, download it by using wget.

root@demohost:~# mkdir /etc/seafile
root@demohost:~# mkdir /etc/seafile/install
root@demohost:~# cd /etc/seafile/
root@demohost:/etc/seafile#  wget https://bintray.com/artifact/download/seafile-org/seafile/seafile-server_6.0.7_x86-64.tar.gz
root@demohost:/etc/seafile# mv seafile-server* install/

3. Run Seafile installer

To start the installation setup, change to the folder where we extracted the installation package and make the seafile setup script executable.

root@demohost:/etc/seafile# cd install/seafile-server-6.0.7/
root@demohost:/etc/seafile/install/seafile-server-6.0.7# chmod u+x setup-seafile.sh

Now execute the seafile setup script.

root@demohost:/etc/seafile/install/seafile-server-6.0.7# ./setup-seafile-mysql.sh

Checking python on this machine ...
Checking python module: setuptools ... Done.
Checking python module: python-imaging ... Done.
Checking python module: python-mysqldb ... Done.
-----------------------------------------------------------------
This script will guide you to setup your seafile server using MySQL.
Make sure you have read seafile server manual at

https://github.com/haiwen/seafile/wiki

Press ENTER to continue
-----------------------------------------------------------------

What is the name of the server? It will be displayed on the client.
3 - 15 letters or digits
[ server name ] LinoxideSeafile

What is the ip or domain of the server?
For example: www.mycompany.com, 192.168.1.101
[ This server's ip or domain ] demohost.com

Where do you want to put your seafile data?
Please use a volume with enough free space
[ default "/etc/seafile/install/seafile-data" ]

Which port do you want to use for the seafile fileserver?
[ default "8082" ]

-------------------------------------------------------
Please choose a way to initialize seafile databases:
-------------------------------------------------------

[1] Create new ccnet/seafile/seahub databases
[2] Use existing ccnet/seafile/seahub databases

[ 1 or 2 ] 1

What is the host of mysql server?
[ default "localhost" ]

What is the port of mysql server?
[ default "3306" ]

What is the password of the mysql root user?
[ root password ]

verifying password of user root ...  done

Enter the name for mysql user of seafile. It would be created if not exists.
[ default "seafile" ]

Enter the password for mysql user "seafile":
[ password for seafile ]

Enter the database name for ccnet-server:
[ default "ccnet-db" ]

Enter the database name for seafile-server:
[ default "seafile-db" ]

Enter the database name for seahub:
[ default "seahub-db" ]

---------------------------------
This is your configuration
---------------------------------

server name:            LinoxideSeafile
server ip/domain:     demohost.com

seafile data dir:       /etc/seafile/install/seafile-data
fileserver port:        8082

database:                  create new
ccnet database:         ccnet-db
seafile database:        seafile-db
seahub database:       seahub-db
database user:           seafile

---------------------------------
Press ENTER to continue, or Ctrl-C to abort
---------------------------------

Generating ccnet configuration ...
done
Successly create configuration dir /etc/seafile/install/ccnet.
Generating seafile configuration ...
Done.
done
Generating seahub configuration ...

----------------------------------------
Now creating seahub database tables ...
----------------------------------------

creating seafile-server-latest symbolic link ...  done

-----------------------------------------------------------------
Your seafile server configuration has been finished successfully.
-----------------------------------------------------------------

run seafile server:     ./seafile.sh { start | stop | restart }
run seahub  server:     ./seahub.sh  { start <port> | stop | restart <port> }

-----------------------------------------------------------------
If you are behind a firewall, remember to allow input/output of these tcp ports:
-----------------------------------------------------------------

port of seafile fileserver:   8082
port of seahub:                8000

When problems occur, Refer to
https://github.com/haiwen/seafile/wiki  for information

4. Start Seafile storage server/Seahub

To start the seafile storage server, execute the seafile script.

root@demohost:~# cd /etc/seafile/install/seafile-server-6.0.7

root@demohost:/etc/seafile/install/seafile-server-6.0.7# ./seafile.sh start

[01/31/17 07:18:55] ../common/session.c(132): using config file /etc/seafile/install/conf/ccnet.conf
Starting seafile server, please wait ...
Seafile server started
Done.

Now start seahub.

root@demohost:/etc/seafile/install/seafile-server-6.0.7# ./seahub.sh start

LC_ALL is not set in ENV, set to en_US.UTF-8
Starting seahub at port 8000 ...

----------------------------------------
It's the first time you start the seafile server. Now let's create the admin account
----------------------------------------

What is the email for the admin account?
[ admin email ] admin@linoxide.com

What is the password for the admin account?
[ admin password ]

Enter the password again:
[ admin password again ]
----------------------------------------
Successfully created seafile admin
----------------------------------------
Seahub is started
Done.

5. Start Seafile during boot-time

To control seafile storage server easily, set it up as an init service, create a startup script inside /etc/init.d/ directory to start seafile/seahub at  boot-time.

root@demohost:~# vi /etc/init.d/seafile

and add the following

#!/bin/bash
# Change the value of "user" to your linux user name

user=root

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

seafile_dir=/etc/seafile/install
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

Create a file /etc/init/seafile.conf and add the following.

root@demohost:/etc/seafile/install/seafile-server-6.0.7# vi /etc/init/seafile.conf

start on (started mysql and runlevel [2345])
stop on (runlevel [016])
pre-start script
/etc/init.d/seafile start
end script
post-stop script
/etc/init.d/seafile stop
end script

Make the seafile script executable.

root@demohost:/etc/seafile/install/seafile-server-6.0.7# sudo chmod +x /etc/init.d/seafile

Start/stop seafile server using following commands

root@demohost:~# /etc/init.d/seafile stop
root@demohost:~# /etc/init.d/seafile start

6. Configure firewall

Configure firewall to allow inbound traffic to seafile server.

For IPTABLES user:

root@demohost:~# sudo iptables -A INPUT -m state –state NEW -p tcp –dport 8000 -j ACCEPT

root@demohost:~# sudo iptables -A INPUT -m state –state NEW -p tcp –dport 8082 -j ACCEPT

Restart iptables

root@demohost:~# service iptables restart

For UFW user:

root@demohost:~# sudo ufw allow 8000/tcp

root@demohost:~# sudo ufw allow 8082/tcp

root@demohost:~# sudo ufw reload

7. Login to Seahub

Now open your favorite browser to access the seahub dashboard to manage shared libraries and folders etc. by typing FQDN or Server’s IP address along with configured default port.  Login with admin email address and password that we have created during the seahub server startup.

Seafile Login

You will now be redirected to dashboard.

Seafile Dashboard

Click "New Library"

Seafile Create folders

Enter Name of the library, tick encrypt if you want, a password and click "Select". You will be redirected to inside newly created directory to upload files, creating more directories etc.

Seafile display libraries

8. Seafile client side configuration

Seafile Server setup is ready. Download seafile client for windows 7.  You have the option of installing seafile client according to your OS.

Download Seafile Client

 

Once you have downloaded the installer for seafile client , execute the installer. The installation wizard will start. Click "Next"

Seafile client installation step1

Choose the destination folder.

Seafile client installation step2

Click "Install"

Seafile client installation step3

Click "Finish"

Seafile client installation complete

Execute seafile client from the start-up menu. Choose a seafile folder and click "Next"

Seafile choose local folder

Enter the server domain along with port no, e-mail, password and click "Login", you will be greeted with seafile applet from where you can browse the server for files, upload etc.

Seafile connect to Server

Double click "My documents" from seafile applet.

Seafile client applet

Provide the password to open the library and click "Ok".

Provide seafile library password

You can now add files in the seafile server either by dragging the files to "Cloud file browser" or by clicking "+" sign.

Seafile upload files

Conclusion

You are now ready to use seafile. In seafile, you access all the files through drive client which maps storage space in seafile server as a virtual drive of your local storage  You can access all the files in the seafile without syncing them. The drive client extends your local storage with the storage capacity of  seafile server.  The security, sharing options and running seafile server for free are most appealing to choose seafile cloud storage. Hope you have enjoyed this tutorial. Thanks for reading the article.

About Dwijadas Dey

Dwijadas Dey is working with GNU/Linux, Open source systems since 2005. Having avid follower of GNU/Linux, He believes in sharing and spreading the open source ideas to the targeted audience. Apart from freelancing he also writes for community. His current interest includes information and network security.

Author Archive Page

Have anything to say?

Your email address will not be published. Required fields are marked *

All comments are subject to moderation.