How To Install Seafile (Secure Cloud Storage) with MySQL Database

To Install Seafile (Secure Cloud Storage) with MySQL Database

Files that are stored on a central server can be synchronized with personal computers and mobile devices via the Seafile client File. It' s functionality is similar to other popular services such as Drop box and Google Drive. Seafile is a cloud storage platform for enterprise environments. It focuses on safety and reliability. Installation of Seafile (Secure Cloud Storage) with MySQL Database in RHEL/CentOS/SL 7.x/6.x is explained in this article.

Features

  • All communication between client and server is encrypted
  • The encryption happens on the client and not on the server
  • Seafile client apps are available for most major operating systems like Windows, Mac OS X and Linux
  • Seafile focuses on file synchronization and team collaboration

Requirements

  • Python-setuptools
  • Python-simplejson
  • CentOS 7 installation with static IP address.
  • MySQL/MariaDB database
  • Python 2.6.5+ or 2.7
  • Python-imaging
  • Python-mysqldb

To Install Python Modules

Update your system, then install all the required Python modules using the following command.

[root@linuxhelp1 ~]# yum install python-imaging MySQL-python python-setuptools -y
Loaded plugins: fastestmirror, langpacks
base                                                                                                | 3.6 kB  00:00:00     
extras                                                                                              | 3.4 kB  00:00:00     
updates                                                                                             | 3.4 kB  00:00:00     
updates/7/x86_64/primary_db                                                                         | 4.9 MB  00:00:14     
Loading mirror speeds from cached hostfile
 * base: mirror.nbrc.ac.in
 * extras: mirror.nbrc.ac.in
 * updates: mirror.nbrc.ac.in
.
.
.
Installed:
  MySQL-python.x86_64 0:1.2.3-11.el7                     python-pillow.x86_64 0:2.0.0-19.gitd1c6db8.el7                    

Complete!

In Debian or Ubuntu server

Install all Python modules with the following command.

$ sudo apt-get update
$ sudo apt-get install python2.7 python-setuptools python-simplejson python-imaging python-mysqldb

To Install Seafile Server

After installing all Python modules create a new user with a strong password that will be used to host Seafile server configuration, then switch to newly created user account.

[root@linuxhelp1 ~]# adduser seafile
[root@linuxhelp1 ~]# passwd seafile
Changing password for user seafile.
New password: 
BAD PASSWORD: The password is shorter than 8 characters
Retype new password: 
passwd: all authentication tokens updated successfully.
[root@linuxhelp1 ~]# su - seafile
[seafile@linuxhelp1 ~]$

Then login to the MySQL database and create three databases, one for each Seafile Server components: ccnet server, seafile server and seahub with a single user for all databases.

seafile@linuxhelp1 ~]$ mysql -u root -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with   or g.
Your MariaDB connection id is 12
Server version: 5.5.47-MariaDB MariaDB Server

Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.

Type ' help '  or ' h'  for help. Type ' c'  to clear the current input statement.

MariaDB [(none)]>  create database `ccnet-db` 
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]>  create database `seafile-db` 
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]>  create database `seahub` 
Query OK, 1 row affected (0.03 sec)

MariaDB [(none)]>  create user ' seafile' @' localhost'  identified by ' linuxc'  
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]>  GRANT ALL PRIVILEGES ON `ccnet-db`.* to `seafile`@`localhost` 
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]>  GRANT ALL PRIVILEGES ON `seafile-db`.* to `seafile`@`localhost` 
Query OK, 0 rows affected (0.01 sec)

MariaDB [(none)]>  GRANT ALL PRIVILEGES ON `seahub-db`.* to `seafile`@`localhost` 
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]>  FLUSH PRIVILEGES 
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]>  exit 
Bye

Navigate to the Seafile official page and download the latest version. Or download the tar file by using wget command, and then extract it to your home Seafile created user earlier.

[seafile@linuxhelp1 ~]$ wget https://bintray.com/artifact/download/seafile-org/seafile/seafile-server_5.1.3_x86-64.tar.gz
--2016-06-08 15:59:37--  https://bintray.com/artifact/download/seafile-org/seafile/seafile-server_5.1.3_x86-64.tar.gz
Resolving bintray.com (bintray.com)... 119.81.184.206
Connecting to bintray.com (bintray.com)|119.81.184.206|:443... connected.
.
.
.
Connecting to akamai.bintray.com (akamai.bintray.com)|23.35.83.168|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 21693528 (21M) [application/octet-stream]
Saving to: ‘ seafile-server_5.1.3_x86-64.tar.gz’ 

100%[=================================================================================> ] 2,16,93,528  577KB/s   in 36s    

2016-06-08 16:00:15 (584 KB/s) - ‘ seafile-server_5.1.3_x86-64.tar.gz’  saved [21693528/21693528]
[seafile@linuxhelp1 ~]$ tar xfz seafile-server_5.1.3_x86-64.tar.gz 
[seafile@linuxhelp1 ~]$ cd seafile-server-5.1.3/
[seafile@linuxhelp1 seafile-server-5.1.3]$

Run setup-seafile-mysql.sh initialization script to install Seafile Server using MySQL database. Once the script is started, it will check the existence of all Python modules required.

[seafile@linuxhelp1 seafile-server-5.1.3]$ ./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 ] linuxhelp

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

Where do you want to put your seafile data?
Please use a volume with enough free space
[ default " /home/seafile/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 " root"  ] seafile

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

verifying password of user seafile ...  done

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:            linuxhelp
    server ip/domain:       www.linuxhelp1.com, 192.168.5.112

    seafile data dir:       /home/seafile/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
Successfully create configuration dir /home/seafile/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  | stop | restart  }
-----------------------------------------------------------------
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.

After the installation is completed, it will generate some useful information such as what ports needs to be open on your Firewall to allow external connection and what scripts to handle in order to start the server.

To Open Firewall and Create Seafile init Script

Before starting the Seafile server from local script for a test, change back to root account and open iptables firewall configuration file located on /etc/sysconfig/ system path. Now edit the following rules before REJECT line and then restart iptables to apply new rules.

[seafile@linuxhelp1 seafile-server-5.1.3]$ su - root
Password: 
Last login: Tue Jun  7 16:11:54 IST 2016 on :0
[root@linuxhelp1 ~]# firewall-cmd --permanent --add-port=80/tcp
success
[root@linuxhelp1 ~]# firewall-cmd --permanent --add-port=8000/tcp
success
[root@linuxhelp1 ~]# firewall-cmd --permanent --add-port=8082/tcp
success
[root@linuxhelp1 ~]# firewall-cmd --permanent --add-port=10001/tcp
success
[root@linuxhelp1 ~]# firewall-cmd --permanent --add-port=12001/tcp
success
[root@linuxhelp1 ~]# firewall-cmd --reload
Success

If you changed Seafile standard ports on installation process update your Firewall iptables rules accordingly.

In seafile server, switch to Seafile user and go to the seafile-server directory. Now start the server using seafile.sh and seahub.sh scripts.

The very first time when you start seahub.sh script, it prompt you to create an administrative account for Seafile Server using your email address with a strong password.

[root@linuxhelp1 ~]# su - seafile
Last login: Wed Jun  8 15:43:34 IST 2016 on pts/0
[seafile@linuxhelp1 ~]$ cd seafile-server-latest/
[seafile@linuxhelp1 seafile-server-latest]$ ./seafile.sh start

[06/08/16 16:06:16] ../common/session.c(132): using config file /home/seafile/conf/ccnet.conf
Starting seafile server, please wait ...
Seafile server started
Done.

[seafile@linuxhelp1 seafile-server-latest]$ ./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@mail.in

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.

After the server is started successfully, open a browser and navigate to your server IP address or domain name on port 8000 using HTTP protocol, then login using your created admin account before.

http://system_IP:8000

OR

http://domain_name:8000


To create new library



To add users

To add an user, select the tools icon at right corner and then click " Users" from left menu.


Here the user can be created or imported. Click " Add User" and fill the credentials.



Download the client software from the official page to access from the client system easily. Now I am going to access from my windows client system


In pop-up window, choose yes to download the default library and to create a virtual disk

Thus the library has successfully mapped with the windows client system.

FAQ
Q
How to login to the MySQL database ?
A
To login to the MySQL database use the following command

mysql -u root -p
Q
How to initialize script to install Seafile Server using MySQL database
A
To initialize script to install Seafile Server using MySQL database

Run setup-seafile-mysql.sh
Q
What are the Python modules required for Seafile ?
A
Python modules required for Seafile are python2.7 python-setuptools python-simplejson python-imaging python-mysqldb
Q
How to install Seafile with MySql on ubuntu?
A
To install Seafile with MySql on ubuntu just follow this link, https://www.linuxhelp.com/how-to-install-seafile-in-ubuntu/
Q
how to install next cloud on ubuntu ?
A
To install next cloud on ubuntu follow this link, https://www.linuxhelp.com/how-to-install-nextcloud-13-on-ubuntu-18-04/