Installing Seafile file storage on Centos 7

A series of articles on setting up file storage Seafile

  • Installing Seafile 7.1.0 + Nginx + Percona on Centos 7
  • Installing Seafile file storage on Centos 7
  • Transferring Seafile file storage with all data to another server
  • Clearing File History in Seafile

Seafile is an open source file storage system. Analogue of Dropbox. On the official website, you can download clients for file synchronization for both desktop operating systems (Windows, Linux, Mac) and mobile devices (Android, iOS)

Installing Seafile

Add EPEL repository and update

[[email protected]]# yum install epel-release
[[email protected]]# yum update

Installing the required set of software

[[email protected]]# yum install nano python-imaging MySQL-python python-simplejson python-setuptools mariadb mariadb-server

Disable Selinux

[[email protected]]# setenforce 0
[[email protected]]# nano /etc/sysconfig/selinux
SELINUX=disabled

Install the Apache Web Server, add it to startup and run

Add ssl support to Apache and restart the service

[[email protected]]# yum install mod_ssl
[[email protected]]# systemctl restart httpd.service

Install MySQL server (MariaDB), add it to startup and run

Connecting to the database as root user

[[email protected]]# mysql -u root -p

We create 3 databases, a user, set a password for the user and assign privileges to him

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 'seafile'@'localhost' identified by 'password';
mysql> GRANT ALL PRIVILEGES ON `ccnet_db`.* to `seafile`@`localhost`;
mysql> GRANT ALL PRIVILEGES ON `seafile_db`.* to `seafile`@`localhost`;
mysql> GRANT ALL PRIVILEGES ON `seahub_db`.* to `seafile`@`localhost`;
mysql> FLUSH PRIVILEGES;
mysql> exit;

Create a directory where we will install Seafile, go to it and download the distribution kit from the official website

[[email protected]]# mkdir -p /home/seafile
[[email protected]]# cd /home/seafile
[[email protected]]# wget https://download.seadrive.org/seafile-server_6.0.9_x86-64.tar.gz

Unzip the distribution, rename and start the installation process

[[email protected]]# tar -xzvf seafile-server_6.0.9_x86-64.tar.gz
[[email protected]]# mv seafile-server-6.0.9 seafile-server
[[email protected]]# cd seafile-server/
[[email protected]]# ./setup-seafile-mysql.sh

During the installation process, the system will ask some questions that need to be answered

server name - seafile
server's ip or domain - 192.168.1.45
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 - 'seafile'
and the password is 'password'
ccnet database is 'ccnet_db'
seafile database is 'seafile_db'
seahub database is 'seahub_db'

Your seafile server configuration has been finished successfully.
-----------------------------------------------------------------
run seafile server:     ./seafile.sh { start | stop | restart }
run seahub  server:     ./seahub.sh  { start <port> | stop | restart <port> }
-----------------------------------------------------------------
If you are behind a firewall, remember to allow input/output of these tcp ports:
-----------------------------------------------------------------
port of seafile fileserver:   8082
port of seahub:               8000

Change the owner and group of the directory where Seafile is installed and the directory with temporary files Seafile

[[email protected]]# chown -R apache:apache /home/seafile
[[email protected]]# chown -R apache:apache /tmp/seahub_cache

Create a service startup script seafile.service

[[email protected]]# nano /etc/systemd/system/seafile.service
[Unit]
Description=Seafile Server
Before=seahub.service
After=network.target mariadb.service

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

[Install] WantedBy=multi-user.target

Create a service startup script seahub.service

[[email protected]]# nano /etc/systemd/system/seahub.service
[Unit]
Description=Seafile Hub
After=network.target seafile.target mariadb.service

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

[Install] WantedBy=multi-user.target

Reboot the systemd daemon and start the created services

[[email protected]]# systemctl daemon-reload
[[email protected]]# systemctl start seafile
[[email protected]]# systemctl start seahub

Apache configuration

Add vhosts – multiple sites on one ip-address

[[email protected]]# nano /etc/httpd/conf.d/vhosts.conf
# Загрузка моих vhosts
IncludeOptional vhosts.d/*.conf

Create a directory where vhosts configurations will be located

[[email protected]]# mkdir /etc/httpd/vhosts.d

Create a configuration file for Seafile

[[email protected]]# nano /etc/httpd/vhosts.d/seafile.example.ru.conf
<VirtualHost *:80>
 ServerName seafile.example.ru
 ServerSignature Off
 
 Redirect / https://seafile.example.ru/

</VirtualHost>

<VirtualHost *:443>
 ServerName seafile.example.ru
 ServerSignature Off

 Alias /media  /home/seafile/seafile-server-latest/seahub/media

# Каталог, где лежать ssl-сертификаты надо создать заранее
 SSLEngine on
 SSLCertificateFile /etc/httpd/ssl/example.ru/certificate.crt
 SSLCertificateKeyFile /etc/httpd/ssl/example.ru/private.key

 SSLProxyEngine on
 SSLProxyCheckPeerCN on
 SSLProxyCheckPeerExpire on

# seafile httpserver
 ProxyPass /seafhttp http://127.0.0.1:8082
 ProxyPassReverse /seafhttp http://127.0.0.1:8082
 RewriteRule ^/seafhttp - [QSA,L]

# seahub
 ProxyPass / http://127.0.0.1:8000/
 ProxyPassReverse / http://127.0.0.1:8000/
 RewriteRule ^/(media.*)$ /$1 [QSA,L,PT]
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteRule ^(.*)$ /seahub.fcgi$1 [QSA,L,E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

 Timeout 2400
 ProxyTimeout 2400
 ProxyBadHeader Ignore

    ErrorLog /home/seafile/error_ssl.log
    CustomLog /home/seafile/access_ssl.log combined
</VirtualHost>

Restarting our services

[[email protected]]# systemctl restart httpd
[[email protected]]# systemctl restart seafile
[[email protected]]# systemctl restart seahub

Add them to startup

[[email protected]]# systemctl enable httpd
[[email protected]]# systemctl enable mariadb
[[email protected]]# systemctl enable seafile
[[email protected]]# systemctl enable seahub

Firewall configuration

Open the necessary ports for Seafile and restart the firewall service

[[email protected]]# firewall-cmd --zone=public --add-port=8000/tcp --permanent
[[email protected]]# firewall-cmd --zone=public --add-port=8082/tcp --permanent
[[email protected]]# firewall-cmd --zone=public --add-port=10001/tcp --permanent
[[email protected]]# firewall-cmd --zone=public --add-port=12001/tcp --permanent
[[email protected]]# firewall-cmd --reload

Additional Information

If you need to fix the URL where the Seafile is loaded, edit one of the configuration files and restart Seafile

[[email protected]]# nano /home/seafile/conf/ccnet.conf
SERVICE_URL = https://share.example.ru

[[email protected]]# systemctl restart seafile
[[email protected]]# systemctl restart seahub
Sidebar