You can support us by downloading this article as PDF from the Link below. Download the guide as PDF

How can I install and configure Seafile on CentOS 8?. Seafile server is an open source, enterprise, self-hosted file hosting platform build for performance and high reliability. Seafile enables you to put files on your own server and allow your different devices to sync and access it. You can as well access all the files as a virtual disk. In this blog, we are going to look at how to install and configure Seafile file sharing server on CentOS 8.

The following are some of the important features of Seafile that makes a reliable file sharing platform:

  • File encryption
  • File locking
  • Online editing and co-authoring
  • File Versioning and Snapshot
  • Mobile File Access
  • Easy to install and use client
  • File Sharing and Permission Control

Install Seafile Storage Server on CentOS 8

These are the steps you’ll follow to install and configure Seafile Storage Server on CentOS 8 system.

Step 1: Update System and Set hostname

We will first disable CentOS selinux to ensure that it does not prevent any installation we are going to perform.

$ sudo vim /etc/selinux/config
# This file controls the state of SELinux on the system. 
# SELINUX= can take one of these three values: 
#     enforcing - SELinux security policy is enforced. 
#     permissive - SELinux prints warnings instead of enforcing. 
#     disabled - No SELinux policy is loaded. 
SELINUX=disabled
# SELINUXTYPE= can take one of these three values: 
#     targeted - Targeted processes are protected, 
#     minimum - Modification of targeted policy. Only selected processes are protected.  
#     mls - Multi Level Security protection. 
SELINUXTYPE=targeted

After disabling Selinux, run updates on your CentOS 8.

sudo dnf -y update
sudo dnf -y upgrade

Now configure hosts file and set server hostname

sudo hostnamectl set-hostname seafile.example.com
echo “<your-server-ip> seafile.example.com” | sudo tee -a /etc/hosts

Reboot your system

sudo reboot

Step 2: Add EPEL repo and install dependencies

First let us install Seafile dependencies and required packages

sudo dnf -y install epel-release
sudo dnf -y install python3 python3-imaging MySQL-python3 python3-simplejson python3-setuptools mariadb mariadb-server nginx

Step 3: Configure MariaDB Database Server

We have already installed MariaDB when installing dependencies. Let us go ahead to configure it. Start MariaDB and enable it to start on system boot.

sudo systemctl start mariadb
sudo systemctl enable mariadb

Secure mariadb installation and set root password.

$ sudo mysql_secure_installation
Enter current password for root (enter for none):  Press Enter
Set root password? [Y/n] y
New password:  Enter New Password
Re-enter new password:  Repeat New Password 
Remove anonymous users? [Y/n] Y 
Disallow root login remotely? [Y/n] Y 
Remove test database and access to it? [Y/n] Y 
Reload privilege tables now? [Y/n] Y 
... Success! 
Cleaning up... 
All done!  If you've completed all of the above steps, your MariaDB

Step 4: Create Seafile Databases

Having configured MariaDB, we will go ahead to create Seafile user and databases. Connect to MySQL using the command below and type the password you set above.

mysql -u root -p 

We will create a user for Seafile and the following three databases:

  • ccnet_db
  • seafile_db
  • seahub_db

Once you connect to MySQL, run the following commands to create the required databases:

create database ccnet_db character set = 'utf8';
create database seafile_db character set = 'utf8';
create database seahub_db character set = 'utf8';
create user [email protected] identified by 'yourpassword';
grant all privileges on ccnet_db.* to [email protected] identified by 'yourpassword';
grant all privileges on seafile_db.* to [email protected] identified by 'yourpassword';
grant all privileges on seahub_db.* to [email protected] identified by 'yourpassword';
flush privileges;
exit

Step 5: Install Seafile on CentOS 8

We are going to install Seafile in /var/www path.

sudo mkdir -p /var/www/seafile
cd /var/www/seafile

Download Seafile with wget command, and extract the downloaded archive.

wget https://s3.eu-central-1.amazonaws.com/download.seadrive.org/seafile-server_7.1.5_x86-64.tar.gz

Extract the downloaded file

sudo tar xvf seafile-server_7.1.5_x86-64.tar.gz 

Rename the directory to ‘seafile-server’ and switch to that directory.

 sudo mv seafile-server-7.1.5/ seafile-server

Step 6: Configure Seafile on CentOS 8

Execute the ‘setup-seafile-mysql.sh‘ file to configure the database.

$ cd  seafile-server
$ sudo ./setup-seafile-mysql.sh

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

       https://download.seafile.com/published/seafile-manual/home.md 

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 ] seafile 
What is the ip or domain of the server? 
For example: www.mycompany.com, 192.168.1.101 
[ This server's ip or domain ] seafile.example.com

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

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

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

Which mysql user to use for seafile? 
[ mysql user for seafile ] seacloud

What is the password for mysql user "seahub"? 
[ password for seahub ]  Enter seacloud password
                                                                                                                 
verifying password of user seacloud ...  done 

Enter the existing database name for ccnet: 
[ ccnet database ] ccnet_db 

verifying user "seacloud" access to database ccnet_db ...  done 

Enter the existing database name for seafile: 
[ seafile database ] seafile_db 

verifying user "seacloud" access to database seafile_db ...  done 

Enter the existing database name for seahub: 
[ seahub database ] seahub_db 

verifying user "seacloud" access to database seahub_db ...  done 

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

   server name:            seafile 
   server ip/domain:       seafile.example.com 

   seafile data dir:       /var/www/seafile/seafile-data 
   fileserver port:        8082 

   database:               use existing 
   ccnet database:         ccnet_db 
   seafile database:       seafile_db 
   seahub database:        seahub_db 
   database user:          seacloud 
--------------------------------- 
Press ENTER to continue, or Ctrl-C to abort

--------------------------------- 

Generating ccnet configuration ... 

done 
Successly create configuration dir /var/www/seafile/ccnet. 
Generating seafile configuration ... 

Done. 
done 
Generating seahub configuration ... 
---------------------------------------- 
Now creating ccnet database tables ... 

---------------------------------------- 
---------------------------------------- 
Now creating seafile database tables ... 

---------------------------------------- 
---------------------------------------- 
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://download.seafile.com/published/seafile-manual/home.md 

for information. 

Now we can start the seafile and seahub services. Start seafile with the below command:

$ sudo ./seafile.sh start
[08/17/20 11:16:33] ../common/session.c(148): using config file /var/www/seafile/conf/ccnet.conf 
Starting seafile server, please wait ... 
** Message: seafile-controller.c(563): No seafevents. 

Seafile server started 

Done.

Start seahub service

$ ./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 ] [email protected] 

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

Enter the password again: 
[ admin password again ]  Repeat Admin password
---------------------------------------- 
Successfully created seafile admin 
---------------------------------------- 
!!! 
!!! WARNING: configuration file should have a valid Python extension. 
!!! 

Error:Seahub failed to start. 
Please try to run "./seahub.sh start" again
Seahub Failed to start.

As you can see from the output above, seahub did not start. In order to get the associated error, start seafile with the command below:

$ sudo ./seahub.sh start-fastcgi

from _sha1 import sha1 
ModuleNotFoundError: No module named '_sha1' 
Error:Seahub failed to start.


The output shows that the error is about sha1 which is not supported. I solved this by replacing “from _sha1 import sha1” with “import hashlib” in the file /var/www/seafile/seafile-server/seahub/seahub/repo_api_tokens/models.py. The file appear as below:

$ sudo vim /var/www/seafile/seafile-server/seahub/seahub/repo_api_tokens/models.py
import hashlib 
import hmac 
import uuid 
from django.db import models

Save the file and start seahub again

$sudo ./seafile.sh start
LC_ALL is not set in ENV, set to en_US.UTF-8 
Starting seahub at port 8000 ... 
Seahub is started 
Done.

Step 7: Configure Firewall

If your filewall is active, ensure to open seafile ports through the firewall:

sudo firewall-cmd –permanent –add-port=8000/tcp
sudo firewall-cmd –permanent –add-port=8082/tcp
sudo firewall-cmd --reload

Step 8: Accessing Seafile on Browser

Access seafile from your browser using your hostname/Ip address on port 8000: http://<your-hostname>:8000. If you find that your seafile is not loading on browser, check seafile gunicorn configuration. Ensure that it does not bind to local IP address as shown below:

$ sudo vim /var/www/seafile/conf/gunicorn.conf.py
# default localhost:8000 
#bind = 127.0.0.1:8000
bind = "0.0.0.0:8000"

Save the file and you should be able to lauch seafile on the browser. You should see a page as below:

Login with the admin credentials you configured earlier and you should get a page as shown:

To start adding new folders/files, click on ‘New Library’ and provide a name to your new folder then click ‘submit’.

You should be able to select your new library and either create or upload a folder/file.

Step 9: Configure Seafile Client

We will use Ubuntu 20.04 Client machine to test connectivity to the Seafile Server.

To connect to Seafile on Ubuntu 20.04, first run the below command to install seafile client on Ubuntu 20.04

$ sudo wget https://linux-clients.seafile.com/seafile.asc -O /usr/share/keyrings/seafile-keyring.asc
$ sudo bash -c "echo 'deb [arch=amd64 signed-by=/usr/share/keyrings/seafile-keyring.asc] https://linux-clients.seafile.com/seafile-deb/focal/ stable main' > /etc/apt/sources.list.d/seafile.list"
$ sudo apt update
$ sudo apt install -y seafile-gui

For cli use only, run the command:

sudo apt-get install seafile-cli

Once installed, search for seafile client on your applications and you should see it.

Double click to open and choose a folder for your libraries and click next

Now provide particulars for your seafile server to connect to:

When you click ‘Login’ you should be connected to your seafile server as shown:

That’s it. Enjoy using your Seafile installation. I hope the blog has been informative. Check more interesting guides below:

You can support us by downloading this article as PDF from the Link below. Download the guide as PDF