How to install Seafile on CentOS 7

Seafile on CentOS 7

Introduction

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

then:

# yum install mariadb mariadb-server

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

# systemctl start mysqld

and

# 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, seauser:

# 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> FLUSH PRIVILEGES;
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 nginx:

# 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:

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

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 setup-seafile-mysql.sh

in order to configure the database, execute it:

# ./setup-seafile-mysql.sh

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:

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

During execution, seahub.sh 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 nginx:

# 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:

[Unit]
Description=Seafile - the open source, self-hosted file sync
Before=seahub.service
After=network.target mariadb.service
 
[Service]
Type=oneshot
ExecStart=/var/www/seafile/seafile-server/seafile.sh start
ExecStop=/var/www/seafile/seafile-server/seafile.sh stop
RemainAfterExit=yes
User=nginx
Group=nginx
 
[Install]
WantedBy=multi-user.target

Save, exit and do the same with SeaHub:

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

and paste:

[Unit]
Description=SeaHub
After=network.target seafile.target mariadb.service
 
[Service]
Type=oneshot
ExecStart=/var/www/seafile/seafile-server/seahub.sh start-fastcgi
ExecStop=/var/www/seafile/seafile-server/seahub.sh stop
RemainAfterExit=yes
User=nginx
Group=nginx
 
[Install]
WantedBy=multi-user.target

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:


server {
    listen 80;
    server_name seafile.mydomain.com;

    proxy_set_header X-Forwarded-For $remote_addr;

    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;
    }

    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;
    }

    location /media {
        root /path/to/your/directory;
    }
}

Save, exit and test NGINX, like this:

# nginx -t

Configure domain in ccnet.conf and seahub_setting.py

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

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

and make the change:

SERVICE_URL = http://seafile.mydomain.com

Save, exit and edit SeaHub configuration file:

# $EDITOR /var/www/seafile/conf/seahub_setting.py

There:

# FILE_SERVER_ROOT = 'http://seafile.mydomain.com/seafhttp'

Save, exit and restart services:

# systemctl restart seafile
# systemctl restart seahub

Test Seafile

With a web browser, go to URL: http://seafile.mydomain.com; 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!

  • mobley.barbara

    I was without work for six months time when my early Co-worker eventually strongly recommended me to start off freelancing at home… It was really after I received $5000 in my very first thirty days when I actually believed I am able to do this for a living! Now a days I am delightful than ever… I work-from-home and also I am my own boss now like I always wanted… I see so many unhappy people around me, working the same old boring job that is sucking the life out of them day-after-day… Everytime I notice some-one similar to that I say START FREELANCING MAN! This is where I started out >>>> http://flicom­.­ru/379356

  • I was paid 104000 dollars previous year by doing an internet task moreover I was able to do it by w­orking in my own time f­o­r quite a few hours on a daily basis. I used work opportunity I found out online and so I am excited that I was in a position to make such decent money. It’s genuinely newbie-friendly and therefore I’m so pleased that I discovered out regarding it. Have a look at exactly what I do… http://olaurl­.­com/15cnh

  • Chief executive officer of Facebook!, is explaining to consumers to get started “Work at home” practice, that Loads of people have been doing more than a year now. This season only, I made around $36k up till now with no more than my computer and some extra time, however i have a full-time 9 to 5 job. Even everyone new at all to this, actually make $50/per h undoubtedly and the profit might be even higher over time… This is how i started >> http://adultadda­.­net/2Xn

  • M­a­n­y p­e­o­ple desire t­o ha­v­e a passive earnings at h­o­me, bu­t t­he­y do­n’t kno­w ho­w t­o exactly d­o th­at o­n th­e Int­ernet. Th­ere ar­e a l­ot of w­ays t­o ea­rn great am­ount of mo­ney, b­ut wh­enev­er p­eopl­e t­ry th­at the­y g­et tr­app­ed in a s­cam, And so I am sh­aring wi­th yo­u a g­enuine an­d gu­arante­ed w­ay f­or fre­e to ea­rn hug­e am­ount of mon­ey a­t ho­me.I am earning atleast $10000 monthly since 1 year.Its a web-based job and so easy to do, Even a little child can do this job and make money. If you want a happy and rich life then you should copy and paste this internet site in browser and then follow instructions to get started right now and make Thousands Using the internet……….. http://ipt­.­pw/hhJFA8

  • M­a­n­y p­e­o­ple w­a­nt t­o ha­v­e a passive in­com­e at their, bu­t t­he­y do­n’t kno­w ho­w t­o exactly d­o th­at o­n th­e Int­ernet. Th­ere ar­e a l­ot of w­ays t­o ea­rn am­ount of mo­ney, b­ut wh­enev­er p­eopl­e t­ry th­at the­y g­et tr­app­ed in a s­cam, And so I am sh­aring wi­th yo­u a g­enuine an­d gu­arante­ed w­ay f­or fre­e to ea­rn hug­e am­ount of mon­ey a­t ho­me.I am earning atleast $10000 monthly since 1 year.Its an on-line job and quite simple to do, Even a little boy or girl can do this job and make money on the internet. If you want a happy and wealthy life then you need to copy and paste this web site in web browser and then follow instructions to get started right now and make Thousands Over the internet……….. http://b1z­.­org/38N

  • I have been on a number of systems but nothing worked well for me in the right way. Lastly in 2012 I discovered a system which is crazy. It is quite simple and easy to setup and I started advertising it within few mins.This system works and is perfect for every person regardless of age,educational background or work-related skills.You can get immediate results even if you feel like you have sup-par computer skills.I have earned $1000 within my first week after which I am getting $10000 or even more each month.Thank you for creating this amazing system that is perfect for the average person >>>> http://deliciousurl­.­com//1d

  • Earning profits through online is usually as straightforward (or simply as stressful) just as getting cash offline. Despite the fact that tens of thousands of Advertising and marketing specialists guarantee to possess a secret formula to generate easy lots of cash, the the reality is, while there is no manner you possibly can turn out to be wealthy person right away through clicking on a key or buying a number of e book. Creating wealth using the net calls for working hard and persistence. Whenever you are in a position to invest plenty of time and consequently efforts in it, there are a variety of methods for obtaining extra wealth online.I am obtaining $10 thousand or even far more every month through this work.Here is the quick way to make profit though the others are longer term home money making ideas >>>>> OUOURL.COM/4rfp

  • Have you at all cashed in very much money without offering it for sale something in addition to left out spending time on almost any mlm form of task and one never has to make investments any-thing. Allow me to tell you a project whereby every resources is definitely presented to you and as a consequence its quite a simple and also not difficult gig. No need to setup your domain name and so on., almost all is definitely presented to you with on cost. Customers are going to browse the landing page and you are going to get money for that. It is actually as simple as that. I am taking home huge amounts of funds at home from this job really like $20 thousand once a month or maybe more and if you also prefer to take home money very similar to that then follow these effortless guidelines by seeing this website >>>>> URL4.UK/9kEHN