12th March, 2017 | Tutorials |

How to Install Seafile on CentOS 7

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

Get a Cloud Server

Seafile is a file hosting application. It allows you to store your files on a central server which can be synchronised with personal computers and mobile devices through apps. You can directly access your files from seafile server via server's web interface. It is similar to other file hosting services such as Dropbox and Google Drive. But the difference between seafile and other file hosting services is that seafile is self-hosted file sharing solution for private cloud applications. Some of the features of Seafile are listed below:


To install Seafile on your centos 7 server all you'll need is a CentOS 7 server and root privileges over it. You can always switch between non root user to root user using sudo -i command.

Update the System

Before going through the installation process it is recommended to update your system and upgrade available packages, you can do so using this command.

yum -y update

Disable SELinux

Log in to your server using your root password then edit Selinux configuration file using any text editor here we will use nano text editor, you can also install it using yum -y install nano

nano /etc/sysconfig/selinux

Find the line SELINUX=enforcing and replace it with SELINUX=disabled, save the file and exit from the text editor.

You'll need reboot the server to apply this change so reboot your server using reboot command and wait for server rebooting then log in again to your server as root user.

Installing the Seafile Dependencies

We will need to install some dependencies first to install seafile so here we will install several python packages, MariaDB and Nginx. We begin with the installation of the EPEL repository on our CentOS server.

yum -y install epel-release

Next, install the python packages, MariaDB and Nginx like shown below:

yum -y install python-imaging MySQL-python python-simplejson python-setuptools mariadb mariadb-server nginx

It may take some time so you should wait until all packages are installed.

Configure MariaDB

We have successfully installed MariaDB now we will need to configure MariaDB for Seafile. Start MariaDB and configure the root password with the commands below:

systemctl start mariadb mysql_secure_installation

You'll be asked to provide root password so simply type in your root password and answer yes to all questions by typing Y.

Set root password? [Y/n] Y
New password:
Re-enter 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

We will create 3 databases for seafile:

  1. ccnet_db
  2. seafile_db
  3. seahub_db
  4. And we will create a new user 'seacloud' with the password 'yourpassword'. Replace yourpassword with a secure password.
mysql -u root -p

Type your password and run following queries to create databases and the user for the seafile installation. Execute all queries one by one.

create database ccnet_db character set = 'utf8';
create database seafile_db character set = 'utf8';
create database seahub_db character set = 'utf8';

create user seacloud@localhost identified by 'yourpassword';

grant all privileges on ccnet_db.* to seacloud@localhost identified by 'yourpassword'; grant all privileges on seafile_db.* to seacloud@localhost identified by 'yourpassword'; grant all privileges on seahub_db.* to seacloud@localhost identified by 'yourpassword'; flush privileges; exit

Install Seafile

We have installed all the dependencies required now we are ready to install seafile. Seafile will be executed under the nginx user so we can use nginx as the reverse proxy for the seafile and seahub services.

We will install seafile under the nginx user in the directory '/var/www/seafile', create that dirctory and enter it with cd command.

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

Next, download the Seafile with the wget command, and extract the downloaded archive as shown below:

wget -xzvf seafile-server_6.0.8_x86-64.tar.gz

Next rename the directory to 'seafile-server' and switch to that directory and to do so run following command.

mv seafile-server-6.0.8 seafile-server cd seafile-server/

Now you'll have to execute the '' file to configure the database.


You'll be asked for following information.

server name - Use your server name 
server's ip or domain - ip address of your server
default data dirctory - just press Enter
default port - press Enter
Now for the database configuration, choose number 2
For the MySQL configuration:
use deafult host - localhost
default port - 3306
the mysql user - 'seacloud'
and the password is 'yourpassword'
ccnet database is 'ccnet_db'
seafile database is 'seafile_db'
seahub database is 'seahub_db'

Finally press enter and the script will create the database tables for the seafile. Now let's start the seafile and seahub services using following commands.

./ start ./ start

You'll be asked for the admin configuration like your admin email and password, then the seahub service will running.

We will use a reverse proxy for the seafile server and we will run seafile with a systemd service file. So we need to stop seafile and seahub service for now. So please run following commands to stop these services.

./ stop ./ stop

Configure Seafile and Seahub Service

We need to change the owner of seafile installation directory and seahub_cache directory to nginx user so we can run seafile as nginx user and to do so run following commands.

cd /var/www/ chown -R nginx:nginx chown -R nginx:nginx /tmp/seahub_cache

Next we will need to create a system.service file using any text editor run following command it will do the job for you.

cd /etc/systemd/system/ nano seafile.service

Add following content to the service file.

Description=Seafile Server
Before=seahub.service mariadb.service

[Service] Type=oneshot ExecStart=/var/www/seafile/seafile-server/ start ExecStop=/var/www/seafile/seafile-server/ stop RemainAfterExit=yes User=nginx Group=nginx


Save the file and exit from the text editor and now create a new seahub.service file.

nano seahub.service

Add following content to the seahub.service file.

Description=Seafile Hub mariadb.service

[Service] Type=oneshot ExecStart=/var/www/seafile/seafile-server/ start-fastcgi ExecStop=/var/www/seafile/seafile-server/ stop RemainAfterExit=yes User=nginx Group=nginx


Save the file and exit from the text editor now reload the systemd service and start seafile and seahub.

systemctl daemon-reload systemctl start seafile systemctl start seahub

Generate SSL Certificate Files

We will run seafile and seahub as nginx user over a Nginx proxy. We can use a free SSL certificate file or the paid SSL certificate, this does not matter for the configuration, here we will generate self-signed SSL certificate file with the OpenSSL.

First of all create a ssl directory using following commands.

mkdir -p /etc/nginx/ssl cd /etc/nginx/ssl

Now we can generate self signed certificate files and a dhparam file with command below:

openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048 openssl req -new -x509 -sha256 -days 365 -newkey rsa:2048 -nodes -keyout server.key -out server.crt

You'll have to answer some questions so answer them and then change the permissions of directory and files using these following commands.

chmod -R 700 /etc/nginx/ssl chmod 400 server.* chmod 400 dhparam.pem

Your SSL certificates have been generated now.

Now we will have to configure nginx as a reverse proxy for the seafile-server on port 8000 and 8002 and to do so we will have to create a virtual host for seafile.

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

Add following content to the virtual host file and replace server name with your own.

server {  
        listen        80;
        server_name   cloud.yourServer;
        return 301  https://$host$request_uri;

server { listen 443 ssl; server_name cloud.yourServer; ssl on; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_certificate /etc/nginx/ssl/server.crt; ssl_certificate_key /etc/nginx/ssl/server.key;


location / { fastcgi_pass; 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; 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 /var/www/seafile/seafile-server/seahub; }


Save the file and exit from the text editor and then restart nginx using following command.

systemctl start nginx

It is good to check all the configuration so make sure port 80 and 443 are available in the list that netstat provides:

netstat -plntu

Next, we have to add the domain name to the seafile configuration.

cd /var/www/seafile/ nano conf/ccnet.conf

Change service url to your domain and then save and exit from text editor. SERVICE_URL = https://yourDomain

Now edit the seahub configuration file.

``nano conf/`

Add below configuration on second line.

HTTP_SERVER_ROOT = 'https://yourDomain/seafhttp'

Finally restart seafile and add all services to start at boot time using following command.

systemctl restart seafile systemctl restart seahub systemctl enable nginx systemctl enable mariadb systemctl enable seafile systemctl enable seahub

Configure FirewallD

Start and enable the firewalld services using following commands.

systemctl start firewalld systemctl enable firewalld

Now change firewall rules and then restart these using following commands.

firewall-cmd --zone=public --add-port=80/tcp --permanent firewall-cmd --zone=public --add-port=443/tcp --permanent firewall-cmd --reload

Web Interface of Seafile

Open up your favorite web browser and visit your seafile domain and you'll see a login webpage of seafile.

HP_NO_IMG/data/uploads/users/744ed2f1-2baa-42b2-b09d-ad15a2ae3934/702825325.png" alt=" " />

Type in your admin email and password and click on login button then you'll be redirected to admin dashboard of seafile. Now you can manage your files and data using seafile.

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

Get a Cloud Server