How to install Seafile on CentOS 7

Seafile on CentOS 7


Seafile is a private file hosting platform, similar to Dropbox, Google Drive, OneDrive and Mega. Its parts are released under open source licenses, in particular:

  • Seafile iOS client: Apache License v2
  • Seafile Android client: GPLv3
  • Desktop syncing client: GPLv2
  • Seafile Server core: AGPLv3
  • Seahub (Seafile server Web UI): Apache License v2

It supports file encryption and group sharing.

This tutorial explains how to install Seafile on CentOS 7 with NGINX as your web server and MariaDB as your database.

Getting started

First of all, Seafile is written in Python, so it requires the following dependencies:

# yum install python-imaging MySQL-python python-memcached python-ldap python-urllib3
Install and configure MariaDB

Install MariaDB; available on EPEL:

# yum install epel-release


# yum install mariadb mariadb-server

At the end of this process, start the program and configure the MariaDB root account, executing:

# systemctl start mysqld


# mysql_secure_installation
Set root password? [Y/n]
New password:
Re-enter new password:
Remove anonymous users? [Y/n]
Disallow root login remotely? [Y/n]
Remove test database and access to it? [Y/n]
Reload privilege tables now? [Y/n]

Seafile requires three different databases (one for each component) :

  • ccnet-db
  • seafile-db
  • seahub-db

So, create these databases and a user,



# mysql -u root -p

In the MariaDB shell:

mysql> CREATE DATABASE ccnet-db CHARACTER SET = 'utf8';
mysql> CREATE DATABASE seafile-db CHARACTER SET = 'utf8';
mysql> CREATE DATABASE seahub-db CHARACTER SET = 'utf8';
mysql> CREATE USER 'seauser'@'localhost' IDENTIFIED BY 'user_strong_password';
mysql> GRANT ALL PRIVILEGES ON ccnet-db TO [email protected] IDENTIFIED BY 'user_strong_password';
mysql> GRANT ALL PRIVILEGES ON seafile-db TO [email protected] IDENTIFIED BY 'user_strong_password';
mysql> GRANT ALL PRIVILEGES ON seahub-db TO [email protected] IDENTIFIED BY 'user_strong_password';
mysql> EXIT;
Install NGINX

Since the EPEL repository is available, it’s possible to install NGINX with yum:

# yum install nginx

Start it with systemd:

# systemctl start nginx.service

Create a user and a group, both named



# adduser --user-group --system --no-create-home nginx

Install and configure Seafile

Create a new directory:

# mkdir /var/www/seafile
# cd /var/www/seafile

There, download Seafile with



# wget

Extract the archive:

# tar xf seafile-server_6.0.8_x86-64.tar.gz

Rename the extracted directory:

# mv seafile-server-6.0.8 seafile-server
# cd seafile-server

There is a script, named

in order to configure the database, execute it:

# ./

It will ask for some information:

  • server name: myserver
  • server ip or domain: localhost
  • seafile data dir: press Enter, and it will use the current directory
  • fileserver port: Enter, and it should use 8082

Next, it will display the following:

Please choose a way to initialize Seafile databases:

[1] Create new ccnet/seafile/seahub databases
[2] Use existing ccnet/seafile/seahub databases

Chose option 2, and then:

  • use deafult host: localhost
  • default port: 3306
  • mysql user: ‘seauser’
  • password for Seafile mysql user: ‘user_strong_password’
  • ccnet database: ‘ccnet-db’
  • seafile database: ‘seafile-db’
  • seahub database: ‘seahub-db’

Next, the script will create required tables for Seafile.

Start Seafile and Seahub:

# ./ start
# ./ start

During execution, will ask for admin informations, particularly your email and password.

After this, Seafile will be running and it will be possible to access it with a web browser, at localhost:8000.
Next, you’ll need to configure NGINX as the reverse proxy. But first, it’s necessary to create a systemd service.

Configuring services

Change the Seafile installation directory and cache owner to user



# chown -R nginx:nginx /var/www/*
# chown -R nginx:nginx /tmp/seahub_cache

Then create a service:

# $EDITOR /etc/systemd/system/seafile.service

In this file, paste the following configuration:

Description=Seafile - the open source, self-hosted file sync
Before=seahub.service mariadb.service
ExecStart=/var/www/seafile/seafile-server/ start
ExecStop=/var/www/seafile/seafile-server/ stop

Save, exit and do the same with SeaHub:

# $EDITOR /etc/systemd/system/seahub.service

and paste:

Description=SeaHub mariadb.service
ExecStart=/var/www/seafile/seafile-server/ start-fastcgi
ExecStop=/var/www/seafile/seafile-server/ stop

Save, exit and then:

# systemctl daemon-reload
# systemctl start seafile
# systemctl start seahub

Configure NGINX

Seafile is correctly running, now configure NGINX for running Seafile behind it. Create a new Virtual Host file:

# $EDITOR /etc/nginx/conf.d/seafile.conf

and there:

<span class="hljs-section">server</span> {
    <span class="hljs-attribute">listen</span> <span class="hljs-number">80</span>;
    <span class="hljs-attribute">server_name</span>;

    <span class="hljs-attribute">proxy_set_header</span> X-Forwarded-For <span class="hljs-variable">$remote_addr</span>;

    <span class="hljs-attribute">location</span> / {
        <span class="hljs-attribute">fastcgi_pass</span>    <span class="hljs-number"></span>;
        <span class="hljs-attribute">fastcgi_param</span>   SCRIPT_FILENAME     <span class="hljs-variable">$document_root</span><span class="hljs-variable">$fastcgi_script_name</span>;
        <span class="hljs-attribute">fastcgi_param</span>   PATH_INFO           <span class="hljs-variable">$fastcgi_script_name</span>;

        <span class="hljs-attribute">fastcgi_param</span>    SERVER_PROTOCOL        <span class="hljs-variable">$server_protocol</span>;
        <span class="hljs-attribute">fastcgi_param</span>   QUERY_STRING        <span class="hljs-variable">$query_string</span>;
        <span class="hljs-attribute">fastcgi_param</span>   REQUEST_METHOD      <span class="hljs-variable">$request_method</span>;
        <span class="hljs-attribute">fastcgi_param</span>   CONTENT_TYPE        <span class="hljs-variable">$content_type</span>;
        <span class="hljs-attribute">fastcgi_param</span>   CONTENT_LENGTH      <span class="hljs-variable">$content_length</span>;
        <span class="hljs-attribute">fastcgi_param</span>    SERVER_ADDR         <span class="hljs-variable">$server_addr</span>;
        <span class="hljs-attribute">fastcgi_param</span>    SERVER_PORT         <span class="hljs-variable">$server_port</span>;
        <span class="hljs-attribute">fastcgi_param</span>    SERVER_NAME         <span class="hljs-variable">$server_name</span>;
        <span class="hljs-attribute">fastcgi_param</span>   REMOTE_ADDR         <span class="hljs-variable">$remote_addr</span>;

        <span class="hljs-attribute">access_log</span>      /var/log/nginx/seahub.access.log;
        <span class="hljs-attribute">error_log</span>       /var/log/nginx/seahub.<span class="hljs-literal">error</span>.log;
        <span class="hljs-attribute">fastcgi_read_timeout</span> <span class="hljs-number">36000</span>;

    <span class="hljs-attribute">location</span> /seafhttp {
        <span class="hljs-attribute">rewrite</span><span class="hljs-regexp"> ^/seafhttp(.*)$</span> <span class="hljs-variable">$1</span> <span class="hljs-literal">break</span>;
        <span class="hljs-attribute">proxy_pass</span>;
        <span class="hljs-attribute">client_max_body_size</span> <span class="hljs-number">0</span>;
        <span class="hljs-attribute">proxy_connect_timeout</span>  <span class="hljs-number">36000s</span>;
        <span class="hljs-attribute">proxy_read_timeout</span>  <span class="hljs-number">36000s</span>;
        <span class="hljs-attribute">proxy_send_timeout</span>  <span class="hljs-number">36000s</span>;
        <span class="hljs-attribute">send_timeout</span>  <span class="hljs-number">36000s</span>;

    <span class="hljs-attribute">location</span> /media {
        <span class="hljs-attribute">root</span> /path/to/your/directory;

Save, exit and test NGINX, like this:

# nginx -t

Configure domain in ccnet.conf and

Modify the value of


in ccnet.conf to let Seafile know the domain, protocol and port chosen:

# $EDITOR /var/www/seafile/conf/ccnet.conf

and make the change:


Save, exit and edit SeaHub configuration file:

# $EDITOR /var/www/seafile/conf/



Save, exit and restart services:

# systemctl restart seafile
# systemctl restart seahub

Test Seafile

With a web browser, go to URL:; it will show a login form in which you can enter the admin account info you previously created. That’s all! Now you can use Seafile like any other cloud storage system!