GNU/Linux >> Linux Esercitazione >  >> Ubuntu

Installare Seafile con Nginx su Ubuntu 20.04

Seafile è una piattaforma self-hosted per la sincronizzazione e la condivisione di file, con funzioni avanzate di privacy, controllo di versione, crittografia e autenticazione a due fattori. È un'alternativa pratica ai servizi cloud commerciali.

Questo tutorial mostra come installare Seafile su Ubuntu 20.04 con Nginx, MariaDB, HTTPS e gestione dei servizi tramite systemd.

Prerequisiti

  • Server Ubuntu 20.04
  • Accesso root o sudo
  • Dominio che punta al server

Indice

  • Installare le dipendenze Python
  • Installare MariaDB
  • Scaricare Seafile
  • Eseguire l'installer di Seafile
  • Configurare il dominio
  • Creare i servizi systemd
  • Generare i certificati SSL
  • Configurare Nginx come reverse proxy
  • Abilitare il firewall e testare

1. Installare le dipendenze Python

sudo apt update
sudo apt install python3 python3-setuptools python3-pil python3-ldap python3-urllib3 ffmpeg python3-pip python3-mysqldb python3-memcache python3-requests libmemcached-dev -y
pip3 install --timeout=3600 Pillow pylibmc captcha jinja2 sqlalchemy psd-tools django-pylibmc django-simple-captcha python3-ldap

2. Installare e configurare MariaDB

sudo apt install mariadb-server -y
systemctl start mariadb
systemctl enable mariadb
mysql_secure_installation

Crea i database e l'utente Seafile.

mysql -u root -p
create database `ccnet-db` character set = 'utf8';
create database `seafile-db` character set = 'utf8';
create database `seahub-db` character set = 'utf8';
create user 'seafile'@'localhost' identified by 'StrongPassword123';
GRANT ALL PRIVILEGES ON `ccnet-db`.* to `seafile`@localhost;
GRANT ALL PRIVILEGES ON `seafile-db`.* to `seafile`@localhost;
GRANT ALL PRIVILEGES ON `seahub-db`.* to `seafile`@localhost;
exit;

3. Scaricare il server Seafile

Crea un utente dedicato e scarica Seafile con quell'account.

useradd -m -s /bin/bash ryujin
su - ryujin
wget -q https://s3.eu-central-1.amazonaws.com/download.seadrive.org/seafile-server_7.1.3_x86-64.tar.gz
tar -xf seafile-server_7.1.3_x86-64.tar.gz
mv seafile-server-*/ seafile-server/

4. Installare Seafile con MariaDB

su - ryujin
cd seafile-server/
./setup-seafile-mysql.sh

Durante la configurazione inserisci nome server, dominio e dettagli del database. Al termine, avvia una prima volta Seafile e Seahub per creare l'account amministratore.

cd ~/seafile-server-latest/
./seafile.sh start
./seahub.sh start
ss -plnt4
./seafile.sh stop
./seahub.sh stop

5. Configurare Seafile per il dominio

su - ryujin
cd conf/
vim ccnet.conf
SERVICE_URL = https://seafile.example.com
vim seafile.conf
[fileserver]
host = 127.0.0.1
port = 8082
vim seahub_settings.py
FILE_SERVER_ROOT = 'https://seafile.example.com/seafhttp'

6. Eseguire Seafile come servizio systemd

cd /etc/systemd/system/
sudo vim seafile.service
[Unit]
Description=Seafile
After=network.target mysql.service nginx.service

[Service]
Type=forking
ExecStart=/home/ryujin/seafile-server-latest/seafile.sh start
ExecStop=/home/ryujin/seafile-server-latest/seafile.sh stop
User=ryujin
Group=ryujin

[Install]
WantedBy=multi-user.target
sudo vim seahub.service
[Unit]
Description=Seafile hub
After=network.target seafile.service

[Service]
Type=forking
ExecStart=/home/ryujin/seafile-server-latest/seahub.sh start
ExecStop=/home/ryujin/seafile-server-latest/seahub.sh stop
User=ryujin
Group=ryujin

[Install]
WantedBy=multi-user.target
systemctl daemon-reload
systemctl start seafile
systemctl enable seafile
systemctl start seahub
systemctl enable seahub

7. Generare i certificati SSL

sudo apt install certbot -y
certbot certonly --agree-tos --no-eff-email --email you@example.com -d seafile.example.com
openssl dhparam -out /etc/nginx/dhparam.pem 2048

8. Configurare Nginx come reverse proxy

sudo apt install nginx -y
systemctl start nginx
systemctl enable nginx
cd /etc/nginx/sites-available/
sudo vim seafile
server {
    listen 80;
    server_name seafile.example.com;
    return 301 https://$host$request_uri;
}

server {
    listen 443 ssl http2;
    server_name seafile.example.com;

    ssl_certificate /etc/letsencrypt/live/seafile.example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/seafile.example.com/privkey.pem;
    ssl_dhparam /etc/nginx/dhparam.pem;

    client_max_body_size 0;

    location / {
        proxy_pass https://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;
    }

    location /seafhttp {
        rewrite ^/seafhttp(.*)$ $1 break;
        proxy_pass https://127.0.0.1:8082;
        client_max_body_size 0;
        proxy_connect_timeout 36000s;
        proxy_read_timeout 36000s;
        proxy_send_timeout 36000s;
    }

    location /media {
        root /home/ryujin/seafile-server-latest/seahub;
    }
}
sudo ln -s /etc/nginx/sites-available/seafile /etc/nginx/sites-enabled/
nginx -t
systemctl restart nginx

9. Abilitare il firewall

for svc in ssh http https
do
    ufw allow $svc
done
ufw enable
ufw status numbered

10. Testare l'installazione

Visita il dominio Seafile e accedi con l'account amministratore.

https://seafile.example.com/

Crea una cartella e carica un file per verificare che sincronizzazione e archiviazione funzionino correttamente.

Ubuntu
  1. Come installare MariaDB su Ubuntu 20.04 LTS

  2. MediaWiki su Nginx e Ubuntu 16.04: installazione con SSL gratuito

  3. Installare Seafile con Nginx e Let's Encrypt su Ubuntu 18.04

  4. Come installare Magento con Nginx su Ubuntu 15.10

  5. Come installare ModSecurity con Nginx su Ubuntu 20.04 LTS

Crea il tuo cloud privato con Seafile su Ubuntu 16.04 LTS

Compila Nginx con ngx_pagespeed su Ubuntu 16.04 LTS

Come installare Joomla con Nginx su Ubuntu 18.04 LTS

Come installare phpMyAdmin con Nginx su Ubuntu 18.04 LTS

Installare phpMyAdmin con Nginx su Ubuntu 20.04 LTS

Come Installare Seafile su Ubuntu 20.04 LTS