(Last Updated On: December 16, 2018)

In this blog post, I’ll show you how to Install Seafile Server On Ubuntu 18.04. 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 others and your different devices to sync and access it. You can as well access all the files as a virtual disk.

Features of Seafile

  • Built-in File Encryption:  Files are encrypted before syncing to the server. Even the system admin can’t view the files.
  • Drive Client: Use drive client to access files in the cloud in local S: drive without syncing them.
  • Reliable File Syncing: Has Reliable and efficient file syncing which improves your productivity.
  • Easy to Upgrade: Upgrade can be done by running a simple script within a few seconds
  • Enterprise Ready: Seafile supports AD/LDAP integration, group syncing, fine-grained permission control make the tool easily applied to your enterprise environment.

Seafile Server Requirements

  • HTTP Server – Nginx or Apache
  • Database Server – MySQL or MariaDB
  • Python Tools

Our installation steps will start with installing above software requirements before downloading and setting up a Seafile server. Follow steps below to Install Seafile Server On Ubuntu 18.04.

Step 1: Install MariaDB Database Server

Start with the installation of MariaDB database server using our previous guide below:

Install MariaDB 10.x on Ubuntu 18.04 and CentOS 7

After installation of MariaDB database server, create a user and database for Seafile.

First login to MySQL shell as root user:

$ mysql -u root -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 48
Server version: 10.3.11-MariaDB-1:10.3.11+maria~bionic-log mariadb.org binary distribution

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

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

MariaDB [(none)]>

Three components of Seafile Server need their own databases:

  • ccnet server
  • seafile server
  • seahub server

We will create a database for each of these server components.

CREATE DATABASE seafile_server;
CREATE DATABASE ccnet_server;
CREATE DATABASE seahub_server;

Create database user and grant privileges for created databases.

CREATE USER 'seafile'@'localhost' IDENTIFIED BY 'StrongPassword';
GRANT ALL ON seafile_server.* TO 'seafile'@'localhost';
GRANT ALL ON ccnet_server.* TO 'seafile'@'localhost';
GRANT ALL ON seahub_server.* TO 'seafile'@'localhost';

Confirm access by Logging into the database as seafile user:

$ mysql -u seafile -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 49
Server version: 10.3.11-MariaDB-1:10.3.11+maria~bionic-log mariadb.org binary distribution

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

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

MariaDB [(none)]> SHOW DATABASES;
+--------------------+
| Database           |
+--------------------+
| ccnet_server       |
| information_schema |
| seafile_server     |
| seahub_server      |
+--------------------+
4 rows in set (0.001 sec)

MariaDB [(none)]> QUIT
Bye

Step 2: Install Python dependencies

Seafile depends heavily on Python and its modules. Install required Python dependencies on Ubuntu 18.04 by running the following commands in your terminal.

sudo apt -y install python python-pip python-pil python-ldap python-urllib3 libpython3.6 python-setuptools python-mysqldb python-memcache python-requests ffmpeg

Step 3: Download and Install  Seafile Server

Check the latest release of Seafile server before downloading. This article could be outdated at the time of your installation.

As of this writing, the current version is 6.2.4

sudo apt -y install wget
export VER="6.3.4"
wget https://download.seadrive.org/seafile-server_${VER}_x86-64.tar.gz

Once the file is downloaded, extract the archive to /srv directory.

sudo tar -xvf  seafile-server_${VER}_x86-64.tar.gz -C /srv
sudo mv /srv/seafile-server-${VER} /srv/seafile

There is no installation needed, just run setup script.

cd /srv/seafile/
sudo ./setup-seafile-mysql.sh

The script will guide you to setup your seafile server using MySQL.

$ sudo ./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 ] Seafile-Server

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

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

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

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

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

What is the password for mysql user "seafile"?
[ password for seafile ] 

verifying password of user seafile ...  done

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

verifying user "seafile" access to database ccnet_server ...  done

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

verifying user "seafile" access to database seafile_server ...  done

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

verifying user "seafile" access to database seahub_server ...  done

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

    server name:            Seafile-Server
    server ip/domain:       fileserver.example.com

    seafile data dir:       /srv/seafile-data
    fileserver port:        8082

    database:               use existing
    ccnet database:         ccnet_server
    seafile database:       seafile_server
    seahub database:        seahub_server
    database user:          seafile

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

Generating ccnet configuration ...

done
Successly create configuration dir /srv/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.

Seafile Server will run on port 8082 and the Seafile Web UI will be available on port 8000.

Start Seafile services

Start Seafile server daemon which handles raw file upload, download and synchronization:

# cd /srv/seafile
# ./seafile.sh start 

[12/15/18 05:08:27] ../common/session.c(132): using config file /srv/conf/ccnet.conf
Starting seafile server, please wait ...
Seafile server started

Done.

Then start the Seahub (Django) web frontend service:

[email protected]:/srv/seafile# ./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: <CONFIRM ADMIN PASSWORD>
[ admin password again ] 

----------------------------------------
Successfully created seafile admin
----------------------------------------
Seahub is started
Done.

If you experience issues with Locale settings, set them like below:

export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
export LANGUAGE=en_US.UTF-8

Add the lines to ~/.bashrc file to have persistent LC settings.

Step 4: Create Seafile Systemd Service

I prefer managing Seafile with systemd. Create a systemd unit file for Seafile backend server.

sudo vim /etc/systemd/system/seafile.service

Add:

[Unit]
Description=Seafile
After= mysql.service
After=network.target

[Service]
Type=forking
ExecStart=/srv/seafile-server-latest/seafile.sh start
ExecStop=/srv/seafile-server-latest/seafile.sh stop

[Install]
WantedBy=multi-user.target

Also create one for Seahub

# cat /etc/systemd/system/seahub.service
[Unit]
Description=Seafile
After= mysql.service
After=network.target

[Service]
Type=forking
ExecStart=/srv/seafile-server-latest/seahub.sh start
ExecStop=/srv/seafile-server-latest/seahub.sh stop

[Install]
WantedBy=multi-user.target

Start and enable the services to start on boot:

sudo systemctl daemon-reload
sudo systemctl start seafile && sudo systemctl enable seafile
sudo systemctl start seahub && sudo systemctl enable seahub

Confirm services status:

# systemctl status  seafile
● seafile.service - Seafile
   Loaded: loaded (/etc/systemd/system/seafile.service; disabled; vendor preset: enabled)
   Active: active (running) since Sat 2018-12-15 06:01:19 PST; 14s ago
  Process: 26437 ExecStart=/srv/seafile-server-latest/seafile.sh start (code=exited, status=0/SUCCESS)
    Tasks: 14 (limit: 2319)
   CGroup: /system.slice/seafile.service
           ├─26476 /srv/seafile/seafile/bin/seafile-controller -c /srv/ccnet -d /srv/seafile-data -F /srv/conf
           ├─26478 ccnet-server -F /srv/conf -c /srv/ccnet -f /srv/logs/ccnet.log -d -P /srv/pids/ccnet.pid
           └─26482 seaf-server -F /srv/conf -c /srv/ccnet -d /srv/seafile-data -l /srv/logs/seafile.log -P /srv/pids/seaf-server.pid

Dec 15 06:01:16 ubuntu-01 systemd[1]: Starting Seafile...
Dec 15 06:01:16 ubuntu-01 seafile.sh[26437]: [12/15/18 06:01:16] ../common/session.c(132): using config file /srv/conf/ccnet.conf
Dec 15 06:01:16 ubuntu-01 seafile.sh[26437]: Starting seafile server, please wait ...
Dec 15 06:01:19 ubuntu-01 seafile.sh[26437]: Seafile server started
Dec 15 06:01:19 ubuntu-01 seafile.sh[26437]: Done.
Dec 15 06:01:19 ubuntu-01 systemd[1]: Started Seafile.

# systemctl status  seahub
● seahub.service - Seafile
   Loaded: loaded (/etc/systemd/system/seahub.service; disabled; vendor preset: enabled)
   Active: active (running) since Sat 2018-12-15 06:02:43 PST; 4s ago
  Process: 26572 ExecStart=/srv/seafile-server-latest/seahub.sh start (code=exited, status=0/SUCCESS)
 Main PID: 26600 (python2.7)
    Tasks: 6 (limit: 2319)
   CGroup: /system.slice/seahub.service
           ├─26600 python2.7 /srv/seafile/seahub/thirdpart/gunicorn seahub.wsgi:application -c /srv/conf/gunicorn.conf --preload
           ├─26607 python2.7 /srv/seafile/seahub/thirdpart/gunicorn seahub.wsgi:application -c /srv/conf/gunicorn.conf --preload
           ├─26608 python2.7 /srv/seafile/seahub/thirdpart/gunicorn seahub.wsgi:application -c /srv/conf/gunicorn.conf --preload
           ├─26609 python2.7 /srv/seafile/seahub/thirdpart/gunicorn seahub.wsgi:application -c /srv/conf/gunicorn.conf --preload
           ├─26610 python2.7 /srv/seafile/seahub/thirdpart/gunicorn seahub.wsgi:application -c /srv/conf/gunicorn.conf --preload
           └─26611 python2.7 /srv/seafile/seahub/thirdpart/gunicorn seahub.wsgi:application -c /srv/conf/gunicorn.conf --preload

Dec 15 06:02:38 ubuntu-01 systemd[1]: Starting Seafile...
Dec 15 06:02:38 ubuntu-01 seahub.sh[26572]: LC_ALL is not set in ENV, set to en_US.UTF-8
Dec 15 06:02:38 ubuntu-01 seahub.sh[26572]: Starting seahub at port 8000 ...
Dec 15 06:02:43 ubuntu-01 seahub.sh[26572]: Seahub is started
Dec 15 06:02:43 ubuntu-01 seahub.sh[26572]: Done.
Dec 15 06:02:43 ubuntu-01 systemd[1]: Started Seafile.

Step 5: Configure Nginx Reverse Proxy

Now that you have the services running, it is time to configure nginx as a reverse proxy to the Seafile server.

sudo apt -y install nginx

Create a new configuration file under /etc/nginx/conf.d/seafile.conf with the following contents.

server {
    listen 80;
    listen [::]:80;
    server_name  fileserver.example.com;
    autoindex off;
    client_max_body_size 100M;
    access_log /var/log/nginx/seafile.com.access.log;
    error_log /var/log/nginx/seafile.com.error.log;

     location / {
            proxy_pass         http://127.0.0.1:8000;
            proxy_set_header   Host $host;
            proxy_set_header   X-Real-IP $remote_addr;
            proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header   X-Forwarded-Host $server_name;
            proxy_read_timeout  1200s;
        }

     location /seafhttp {
            rewrite ^/seafhttp(.*)$ $1 break;
            proxy_pass http://127.0.0.1:8082;
            proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_connect_timeout  36000s;
            proxy_read_timeout  36000s;
            proxy_send_timeout  36000s;
            send_timeout  36000s;
        }

    location /media {
            root /srv/seafile-server-latest/seahub;
        }
}

Vist your Seafile server domain name on http://example.com

Enter admin user email and password to login. You should get to Seafile dashboard which looks like below.

You have successfully installed and Configured Seafile Server on Ubuntu 18.04 LTS.

Similar Articles:

Install and Configure Pydio File Sharing Server on Ubuntu 18.04 LTS

How to Install Nextcloud 14 on Ubuntu 18.04/16.04/Debian 9