• Get In Touch
December 15, 2016

How to Install and Configure Seafile on Ubuntu 16.04 Server

Want your very own server? Get our 1GB memory, Xeon V4, 25GB SSD VPS for £10.00 / month.
Get a Cloud Server

Seafile is an open source secure cloud storage platform like Dropbox. It is based on python. You can easily create your own private cloud using Seafile.

Using Seafile you can easily synchronize your files and data with PC and mobile devices. You can manage your all data files from central location using it’s web interface.

The main difference between Seafile and Dropbox is that Seafile is a self-hosted file sharing solution for private cloud applications.

Seafile provides lot’s of features such as :

  1. Public link sharing for uploading and downloading.
  2. Support client side encryption.
  3. Support version control, LDAP authentication and Two-factor authentication.
  4. Antivirus and office web app integration.

In this tutorial, we will learn how to install and configure Seafile on Ubuntu 16.04 server.

Requirements

  • A server running Ubuntu 16.04.
  • A non-root user with sudo privileges configure on your server.
  • A static IP address 192.168.15.100 configure on your server.

Update System

Before starting, you will need to update Ubuntu repository with the latest one.

You can do this by running the following command:

sudo apt-get update -y
sudo apt-get upgrade -y

Installing Required Dependencies

Before starting, you will need to install some packages as a prerequisites of Seafile.
You can install all the required packages by running the following command:

sudo apt-get install openjdk-8-jre poppler-utils libreoffice libreoffice-script-provider-python libpython2.7 python-pip mariadb-server python-setuptools python-memcache ttf-wqy-microhei ttf-wqy-zenhei xfonts-wqy python-imaging python-mysqldb python-pip

Next, you will need to install boto. You can easily install it using pip command:

sudo pip install boto

Create a Seafile User

Next, you will need to create a new seafile user for installation. We will run the seafile server as this user.

Run the following command to create a new user:

sudo useradd -m -s /bin/bash seafile

Set password for seafile user:

sudo password seafile

Downloading Seafile

You can download the latest version of the seafile from it’s official website https://www.seafile.com/en/download/

You can download the seafile with wget command:

First log in as a seafile user with the following command:

su - seafile

Then, download seafile with the following command:

wget https://bintray.com/artifact/download/seafile-org/seafile/seafile-server_6.0.6_x86-64.tar.gz

Once seafile source is downloaded, extract it with the following command:

tar -xvzf seafile-server_6.0.6_x86-64.tar.gz

Next, rename seafile-server_6.0.6 directory to seafile-server:

mv seafile-server_6.0.6 seafile-server

Create the Database for Seafile

You will also need to create three database such as ccnet, seafile and seahub for seafile server.

First, exit from the seafile user shell with the following command:

exit

Next, create three database with one user and grant the user to all databases:

First, login to Mysql:

mysql -u root -p

Create three database with the following command:

MariaDB [(none)]> create database ccnet_db character set = 'utf8';
MariaDB [(none)]> create database seafile_db character set = 'utf8';
MariaDB [(none)]> create database seahub_db character set = 'utf8';

Create a user for these databases:

MariaDB [(none)]> create user seacloud@localhost identified by 'password';

Grant user to the databases:

MariaDB [(none)]> grant all privileges on ccnet_db.* to seacloud@localhost identified by 'password';
MariaDB [(none)]> grant all privileges on seafile_db.* to seacloud@localhost identified by 'password';
MariaDB [(none)]> grant all privileges on seahub_db.* to seacloud@localhost identified by 'password';

Next flush the privileges and exit from the shell:

MariaDB [(none)]> flush privileges;
MariaDB [(none)]> exit

Installing Seafile

Before installing seafile, you will need to login as a seafile user.
To do so, run the following command:

su - seafile

Next, change the directory to seafile-server and install seafile by running setup-seafile-mysql.sh script:

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

During installation you will be asked about Server Name, Domain/IP, Seafile data directory, Seafile server port configuration and database information, provide each information carefully. Once the installation is completed successfully start seafile and the seahub server:

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

You will be asked about the admin email and password for seafile. Provide each details carefully, then stop seafile now.

./seafile.sh stop
./seahub.sh stop

Configuring Seafile Service File

Next, you will need to create seafile and seahub services file to start and stop seafile server.

Create a new service file with named seafile.service inside /lib/systemd/system/ directory:

First, exit from the seafile user shell:

exit

Then create service file for seafile:

sudo nano /lib/systemd/system/seafile.service

Add the following lines:

[Unit]
Description=Seafile Server
After=network.target mariadb.service

[Service]
Type=oneshot
ExecStart=/home/seafile/seafile-server/seafile.sh start
ExecStop=/home/seafile/seafile-server/seafile.sh stop
RemainAfterExit=yes
User=seafile
Group=seafile

[Install]
WantedBy=multi-user.target

Save the file and create a new service file for seahub:

sudo nano /lib/systemd/system/seahub.service

Add the following lines:

[Unit]
Description=Seafile Hub
After=network.target seafile.target

[Service]
Type=oneshot
ExecStart=/home/seafile/seafile-server/seahub.sh start-fastcgi
ExecStop=/home/seafile/seafile-server/seahub.sh stop
RemainAfterExit=yes
User=seafile
Group=seafile

[Install]
WantedBy=multi-user.target

Save the file once you are done.

Next, reload the systemd service and start seafile and seahub:

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

Installing and Configuring Nginx

You will also need to install Nginx and configure it as a reverse proxy server for seafile-server on port 8000 and 8002.

First, install Nginx:

sudo apt-get install nginx

Next, create a new virtualhost file with name seafile.conf:

sudo nano /etc/nginx/sites-available/seafile.conf

Add the following lines:


server { listen 80; server_name 192.168.15.100; proxy_set_header X-Forwarded-For $remote_addr; # Reverse proxy for seafile location / { fastcgi_pass 127.0.0.1:8000; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_script_name; fastcgi_param SERVER_PROTOCOL $server_protocol; fastcgi_param QUERY_STRING $query_string; fastcgi_param REQUEST_METHOD $request_method; fastcgi_param CONTENT_TYPE $content_type; fastcgi_param CONTENT_LENGTH $content_length; fastcgi_param SERVER_ADDR $server_addr; fastcgi_param SERVER_PORT $server_port; fastcgi_param SERVER_NAME $server_name; fastcgi_param REMOTE_ADDR $remote_addr; access_log /var/log/nginx/seahub.access.log; error_log /var/log/nginx/seahub.error.log; fastcgi_read_timeout 36000; } # Reverse Proxy for seahub location /seafhttp { rewrite ^/seafhttp(.*)$ $1 break; proxy_pass http://127.0.0.1:8082; client_max_body_size 0; proxy_connect_timeout 36000s; proxy_read_timeout 36000s; proxy_send_timeout 36000s; send_timeout 36000s; } #CHANGE THIS PATH WITH YOUR OWN DIRECTORY location /media { root /home/seafile/seafile-server/seahub; } }

Save the file and create a symlink of this file to the sites-enabled directory and restart nginx:

sudo ln -s /etc/nginx/sites-available/seafile.conf /etc/nginx/sites-enabled/
systemctl restart nginx

Accessing Seafile Web Interface

Once everything is up to date, it’s time to access seafile web interface.

Open your favourite web browser and type the URL http://192.168.15.100, you will see the following page:

HP_NO_IMG/data/uploads/users/7ecb43a5-b365-4ebf-93d5-f3b632f29f33/636878857.png” alt=”” />

Enter your admin username, password and click on Login button, you will see the seafile default dashboard in following image:

HP_NO_IMG/data/uploads/users/7ecb43a5-b365-4ebf-93d5-f3b632f29f33/1613760481.png” alt=”” />

Congratulations! You have successfully installed Seafile on your Ubuntu 16.04 server.

Want your very own server? Get our 1GB memory, Xeon V4, 25GB SSD VPS for £10.00 / month.
Get a Cloud Server

Share this Article!

Related Posts

Node.js Authentication – A Complete Guide with Passport and JWT

Node.js Authentication – A Complete Guide with Passport and JWT

Truth be told, it’s difficult for a web application that doesn’t have some kind of identification, even if you don’t see it as a security measure in and of itself. The Internet is a kind of lawless land, and even on free services like Google’s, authentication ensures that abuses will be avoided or at least […]

Node.js and MongoDB: How to Connect MongoDB With Node

Node.js and MongoDB: How to Connect MongoDB With Node

MongoDB is a document-oriented NoSQL database, which was born in 2007 in California as a service to be used within a larger project, but which soon became an independent and open-source product. It stores documents in JSON, a format based on JavaScript and simpler than XML, but still with good expressiveness. It is the dominant […]

Using MySQL with Node.js: A Complete Tutorial

Using MySQL with Node.js: A Complete Tutorial

Although data persistence is almost always a fundamental element of applications, Node.js has no native integration with databases. Everything is delegated to third-party libraries to be included manually, in addition to the standard APIs. Although MongoDB and other non-relational databases are the most common choice with Node because if you need to scale an application, […]

Node.Js Vs Django: Which Is the Best for Your Project

Node.Js Vs Django: Which Is the Best for Your Project

Django and NodeJs are two powerful technologies for web development, both have great functionality, versatile applications, and a great user interface. Both are open source and can be used for free. But which one fits your project best? NodeJs is based on JavaScript, while Django is written in Python. These are two equally popular technologies […]

Nodejs Vs PHP:  Which Works Best?

Nodejs Vs PHP: Which Works Best?

Before getting into the “battle” between Node.js and PHP we need to understand why the issue is still ongoing. It all started with the increased demand for smartphone applications, their success forcing developers to adapt to new back-end technologies that could handle a multitude of simultaneous requests. JavaScript has always been identified as a client-side […]