In this tutorial, we will show you how to install Seafile on Ubuntu 20.04 LTS. For those of you who didn’t know, Seafile is an open-source, self-hosted file sync that shares the solution with high performance and reliability. Seafile enables you to put files on your own server and allow others and your different devices to sync and access it. Seafile is written in C and Python programming language and provides similar features like Dropbox, mega.co.nz, and others.
This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo
‘ to the commands to get root privileges. I will show you the step-by-step installation of Seafile open-source file-hosting and cloud storage system on Ubuntu 20.04 (Focal Fossa). You can follow the same instructions for Ubuntu 18.04, 16.04, and any other Debian-based distribution like Linux Mint.
Prerequisites
- A server running one of the following operating systems: Ubuntu 20.04, 18.04, 16.04, and any other Debian-based distribution like Linux Mint.
- It’s recommended that you use a fresh OS install to prevent any potential issues.
- SSH access to the server (or just open Terminal if you’re on a desktop).
- A
non-root sudo user
or access to theroot user
. We recommend acting as anon-root sudo user
, however, as you can harm your system if you’re not careful when acting as the root.
Install Seafile on Ubuntu 20.04 LTS Focal Fossa
Step 1. First, make sure that all your system packages are up-to-date by running the following apt
commands in the terminal.
sudo apt update sudo apt upgrade
Step 2. Step 2. Install Required Dependencies.
Now install required all dependencies needed for Seafile server installation using apt
commands below:
sudo apt install python3 python3-{pip,pil,ldap,urllib3,setuptools,mysqldb,memcache,requests} sudo apt install ffmpeg memcached libmemcached-dev sudo pip3 install --upgrade pip sudo pip3 install --timeout=3600 Pillow pylibmc captcha jinja2 sqlalchemy==1.4.3 sudo pip3 install --timeout=3600 django-pylibmc django-simple-captcha python3-ldap mysqlclient
Step 3. Installing the LEMP stack.
A Ubuntu 20.04 LEMP server is required. If you do not have LEMP installed, you can follow our guide here.
Step 4. Configuring MariaDB.
By default, MariaDB is not hardened. You can secure MariaDB using the mysql_secure_installation
script. you should read and below each step carefully which will set a root password, remove anonymous users, disallow remote root login, and remove the test database and access to secure MariaDB:
mysql_secure_installation
Configure it like this:
- Set root password? [Y/n] y - 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
Next, we will need to log in to the MariaDB console and create a database for the Seafile. Run the following command:
mysql -u root -p
This will prompt you for a password, so enter your MariaDB root password and hit Enter. We will create a database for each of these server components.
MariaDB [(none)]> CREATE DATABASE seafile_server; MariaDB [(none)]> CREATE DATABASE ccnet_server; MariaDB [(none)]> CREATE DATABASE seahub_server;
Then, create a database user and grant privileges for created databases:
MariaDB [(none)]> CREATE USER 'seafile'@'localhost' IDENTIFIED BY 'Your-Strong-Password'; MariaDB [(none)]> GRANT ALL ON seafile_server.* TO 'seafile'@'localhost'; MariaDB [(none)]> GRANT ALL ON ccnet_server.* TO 'seafile'@'localhost'; MariaDB [(none)]> GRANT ALL ON seahub_server.* TO 'seafile'@'localhost'; MariaDB [(none)]> QUIT;
Step 5. Installing Seafile on Ubuntu 20.04.
By default, Seafile is not available on Ubuntu 20.04 base repository. Now run the following command below to download the latest version of Seafile from the official page:
wget https://s3.eu-central-1.amazonaws.com/download.seadrive.org/seafile-server_9.0.4_x86-64.tar.gz
Next, extract the downloaded file:
sudo tar -xvf seafile-server_9.0.4_x86-64.tar.gz -C /srv sudo mv /srv/seafile-server_9.0.4_x86-64 /srv/seafile
After that, run the setup script:
cd /srv/seafile/ sudo ./setup-seafile-mysql.sh
During installation, 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.
Once the installation is complete, Now start the Seafile server using the commands below:
cd /srv/seafile sudo ./seafile.sh start
Then start the Seahub (Django) web frontend service:
sudo ./seahub.sh start
Step 6. Create Seafile Systemd Service.
Now we set up the seafile and seahub as a systemd
service:
sudo tee /etc/systemd/system/seafile.service<<EOF [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 EOF
Also, we create one for Seahub:
sudo tee /etc/systemd/system/seahub.service<<EOF [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 EOF
Save and close the file, then reload the systemd
manager so that the changes take place:
sudo systemctl daemon-reload sudo systemctl start seafile && sudo systemctl enable seafile sudo systemctl start seahub && sudo systemctl enable seahub
Step 7. Configure Nginx as a Reverse-Proxy.
Now we create a new configuration file under /etc/nginx/conf.d/seafile.conf
with the following commands:
server {
listen 80;
listen [::]:80;
server_name seafile.your-domain.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;
}
}
Save and close the file, then restart the Nginx web server so that the changes take place:
nginx -t sudo systemctl restart nginx
Step 8. Configure Firewall.
By default, the UFW firewall is enabled on Ubuntu. Depending on your Nginx virtual host configuration file, open ports 80 and 443 to allow HTTP and HTTPS traffic:
sudo ufw allow 80/tcp sudo ufw allow 443/tcp sudo ufw reload
Step 9. Accessing Seafile Web Interface.
Once successfully installed, open your web browser and access the Seafile web interface using the URL http://seafile.your-domain.com
. You should see the following page:
Congratulations! You have successfully installed Seafile. Thanks for using this tutorial for installing Seafile open-source file-hosting and cloud storage system on Ubuntu 20.04 LTS Focal Fossa system. For additional help or useful information, we recommend you to check the official Seafile website.