How to install the Seafile cloud storage solution on Ubuntu Server 20.04

how-to-install-the-seafile-cloud-storage-solution-on-ubuntu-server-20.04

Seafile is a powerful on-premise cloud solution. Jack Wallen walks you through the process of installing this solution on Ubuntu Server 20.04.

Image: Jack Wallen

In 2016, I outlined the process for installing the Seafile cloud storage solution on Ubuntu Server 16.04. The platform has continued to mature and the installation process has changed. So I thought I’d revisit the process, only this time on Ubuntu Server 20.04.

Seafile still includes the same features (with a few additions). The feature list includes the likes of:

  • Built-in file encryption

  • Easy collaboration

  • Team Wiki

  • Small footprint server, for high performance

  • AD/LDAP integration

  • Create groups with file syncing, online file editing, and more

  • Create libraries (for separate syncing)

  • Automatic file conflict resolution

  • Share libraries, subdirectories, links, files, and more

Let’s make this happen on the latest server release from Canonical.

SEE: Serverless computing: A guide for IT leaders (TechRepublic Premium)

What you’ll need

  • A running/updated instance of Ubuntu Server 20.04 
  • A user with sudo privileges

How to install the dependencies

The first thing we’re going to do is install the necessary dependencies. Log in to your Ubuntu Server and install MySQL with the command:

sudo apt-get install mysql-server -y

Start and enable MySQL with the commands:

sudo systemctl start mysql
sudo systemctl enable mysql

Now we’ll install the NGINX web server with the command:

sudo apt-get install nginx -y

With NGINX installed, start and enable it with the commands:

sudo systemctl start nginx
sudo systemctl enable nginx

Next install the remaining dependencies with the commands:

sudo apt-get install python python-{pip,pil,ldap,urllib3,setuptools,mysqldb,memcache,requests} -y
sudo apt-get install libpython3.6 ffmpeg python3-django-captcha -y

How to secure MySQL and create the database

Before we create the database, we need to secure the MySQL installation with the command:

sudo mysql_secure_installation

Give the admin user a strong/unique password and answer “y” to the remaining questions.

At this point, you can create the database and a Seafile user. Log in to the MySQL prompt with the command:

sudo mysql -u root -p

At the MySQL console, issue the following commands:

  • CREATE DATABASE seafile_server;

  • CREATE DATABASE ccnet_server;

  • CREATE DATABASE seahub_server;

  • CREATE USER ‘seafile’@’localhost’ IDENTIFIED BY ‘PASSWORD’;

  • GRANT ALL ON seafile_server.TO ‘seafile’@’localhost’;

  • GRANT ALL ON ccnet_server.TO ‘seafile’@’localhost’;

  • GRANT ALL ON seahub_server.TO ‘seafile’@’localhost’;

  • QUIT;

Where PASSWORD is a strong/unique password.

How to download and unpack Seafile

We need to download the latest version of Seafile. Do that with the command:

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

With the file download complete, unpack it with the command:

tar xvfz seafile-server_7.1.4_x86-64.tar.gz

Change into the newly-created directory with the command:

cd seafile-server-7.1.4

Create a new directory to house Seafile with the command:

sudo mkdir /srv/seafile

Move the entire contents of the unpacked file into the newly-created directory with the command:

sudo mv /srv/seafile/

How to configure Seafile

Change into the Seafile directory with the command:

cd /srv/seafile

Issue the command:

sudo ./setup-seafile-mysql.sh

You will be asked to answer a few questions regarding your server (name, address, port, etc.). You will also be asked about initializing a database. Make sure to type 1 for creating a new database. You will then be asked to answer another round of questions. The questions and answers should be:

  • mysql server host: localhost

  • mysql server port: 3306

  • root password: the root password for the MySQL server

  • mysql user for Seafile: seafile

  • password for Seafile user: PASSWORD

  • ccnet database name: ccnet-db

  • Seafile database name: seafile-db

  • Seahub database name: seahub-db

Where PASSWORD is a strong/unique password.

How to configure NGINX

We can now configure our NGINX web server. To do that, create a new configuration file with the command:

sudo nano /etc/nginx/conf.d/seafile.conf

In that file, paste the following:

server {
    listen 80;
    listen [::]: 80;
    server_name  SERVERADDRESS;
    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;
        }
}

Where SERVERADDRESS is either the domain or IP address of the hosting server. 

Save and close the file. Restart NGINX with the command:

sudo systemctl restart nginx

How to start the Seafile server

There are two services to start for Seafile. In order to start them both, issue the following two commands:

sudo ./seafile.sh start
sudo ./seahub.sh start

When you run the seahub service for the first time, you will be prompted to create a new admin user. For this you’ll need to use an email address and strong password. After seahub starts, you can then log in to your Seafile instance by pointing it to http://SERVER_IP (where SERVER_IP is the IP address or domain of the hosting server). You will be prompted to log in with the credentials you created during the first run of the seahub service (Figure A).

Figure A

Logging in to Seafile.

Once you’ve logged in, you’ll find yourself on the Seafile main page, where you can start configuring the platform to perfectly suit your needs (Figure B).

Figure B

The Seafile main page.

Congratulations, you now have your very own, self-hosted cloud platform. Enjoy.

http://www.techrepublic.com/

Cloud and Everything as a Service Newsletter

This is your go-to resource for XaaS, AWS, Microsoft Azure, Google Cloud Platform, cloud engineering jobs, and cloud security news and tips.
Delivered Mondays



Sign up today

Also see