Ricerca nel sito web

Come installare il server EteSync su Ubuntu 20.04


Su questa pagina

  1. Prerequisiti
  2. Per iniziare
  3. Installazione del server MariaDB
  4. Installazione e configurazione di EteSync
  5. Crea un file di unità Systemd per EteSync
  6. Configurazione di Apache come proxy inverso
  7. Accedi alla console di amministrazione di EteSync
  8. Proteggi EteSync con Lets Encrypt SSL
  9. Conclusione

EteSync è una soluzione open source per sincronizzare contatti, calendari e attività. È self-hosted, fornisce crittografia end-to-end e consente di condividere dati con altri utenti. Può essere integrato con i desktop GNOME e KDE. È possibile accedervi tramite client desktop, Web, Android e iOS.

In questo tutorial, ti mostrerò come installare EteSync con Apache su Ubuntu 20.04.

Prerequisiti

  • Un server che esegue Ubuntu 20.04.
  • Un nome di dominio valido indicato con l'IP del tuo server.
  • Sul server è configurata una password di root.

Iniziare

Innanzitutto, aggiorna i pacchetti di sistema alla versione aggiornata eseguendo il seguente comando:

apt-get update -y

Una volta aggiornati tutti i pacchetti, puoi procedere al passaggio successivo.

Installazione del server MariaDB

Per impostazione predefinita, EteSync utilizza il database SQLite per archiviare le sue informazioni. Qui installeremo e utilizzeremo MariaDB come database back-end.

Innanzitutto, installa le dipendenze richieste utilizzando il seguente comando:

apt-get install software-properties-common gnupg2 -y

Successivamente, aggiungi la chiave e il repository GPG MariaDB usando il seguente comando:

apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8
add-apt-repository 'deb [arch=amd64,arm64,ppc64el] http://mirror.lstn.net/mariadb/repo/10.5/ubuntu focal main'

Successivamente, aggiorna il repository MariaDB e installa l'ultima versione di MariaDB con il seguente comando:

apt-get install mariadb-server -y

Dopo aver installato il server MariaDB, accedi alla shell MariaDB con il seguente comando:

mysql

Una volta effettuato l'accesso, crea un database e un utente per EteSync con il seguente comando:

MariaDB [(none)]> create database etesync;
MariaDB [(none)]> create user identified by 'securepassword';

Quindi, concedi tutti i privilegi al database EteSync con il seguente comando:

MariaDB [(none)]> grant all privileges on etesync.* to ;

Successivamente, scarica i privilegi ed esci da MariaDB con il seguente comando:

MariaDB [(none)]> flush privileges;
MariaDB [(none)]> exit;

Una volta terminato, puoi procedere al passaggio successivo.

Installazione e configurazione di EteSync

Innanzitutto, dovrai installare alcune dipendenze Python richieste per EteSync. Puoi installarli tutti con il seguente comando:

apt-get install python3-virtualenv python3-pip gcc libmysqlclient-dev build-essential git -y

Dopo aver installato tutte le dipendenze, scarica l'ultima versione di EteSync usando il seguente comando:

git clone https://github.com/etesync/server.git etesync

Una volta completato il download, cambia la directory in etesync e crea un ambiente virtuale Python con il seguente comando:

cd etesync
virtualenv -p python3 .venv

Quindi, attiva l'ambiente virtuale con il seguente comando:

source .venv/bin/activate

Successivamente, installa tutti i requisiti utilizzando il seguente comando:

pip install -r requirements.txt

Successivamente, copia il file di configurazione di esempio:

cp etebase-server.ini.example etebase-server.ini

Successivamente, modifica il file di configurazione utilizzando il comando seguente:

nano etebase-server.ini

Aggiungi o modifica le seguenti righe secondo la tua configurazione:

media_root = /opt
allowed_host1 = etesync.example.com

;engine = django.db.backends.sqlite3
;name = db.sqlite3

engine = django.db.backends.mysql
name = etesync
user = etesync
password = securepassword
host = 127.0.0.1
port = 3306

Salva e chiudi il file, quindi installa altri moduli utilizzando il seguente comando:

pip3 install daphne
pip3 install mysqlclient
pip3 install aioredis

Quindi, genera i file statici ed esegui la migrazione del database con il seguente comando:

./manage.py collectstatic
./manage.py migrate

Infine, avvia il server EteSync con il seguente comando:

daphne -b 0.0.0.0 -p 8001 etebase_server.asgi:application

Se tutto va bene, dovresti ottenere il seguente output:

2021-07-09 05:42:28,510 INFO     Starting server at tcp:port=8001:interface=0.0.0.0
2021-07-09 05:42:28,510 INFO     HTTP/2 support not enabled (install the http2 and tls Twisted extras)
2021-07-09 05:42:28,511 INFO     Configuring endpoint tcp:port=8001:interface=0.0.0.0
2021-07-09 05:42:28,512 INFO     Listening on TCP address 0.0.0.0:8001

Premere CTRL + C per arrestare il server.

Successivamente, crea un utente amministrativo utilizzando il seguente comando:

./manage.py createsuperuser

Fornisci il tuo nome utente, password ed e-mail come mostrato di seguito:

Username: etesync
Email address: 
Password: 
Password (again): 
Superuser created successfully.

Successivamente, disattiva dall'ambiente virtuale Python con il seguente comando:

deactivate

Crea un file di unità Systemd per EteSync

Successivamente, dovrai creare un file di unità systemd per la gestione di EteSync. Puoi crearlo con il seguente comando:

nano /etc/systemd/system/etesync.service

Aggiungi le seguenti righe:

[Unit]
Description=EteSync: End-to-End Encryption to Sync Calender, Contacts, Tasks and Notes.

[Service]
WorkingDirectory=/root/etesync
ExecStart=/root/etesync/.venv/bin/daphne -b 127.0.0.1 -p 8001 -u /tmp/etebase_server.sock etebase_server.asgi:application
User=root
Group=root
Restart=always
RestartSec=5s

[Install]
WantedBy=multi-user.target

Salva e chiudi il file, quindi ricarica il demone systemd per applicare le modifiche alla configurazione:

systemctl daemon-reload

Successivamente, avvia e abilita il servizio EteSync con il seguente comando:

systemctl start etesync
systemctl enable etesync

Per verificare lo stato del servizio EteSync, eseguire il seguente comando:

systemctl status etesync

Otterrai il seguente output:

? etesync.service - EteSync: End-to-End Encryption to Sync Calender, Contacts, Tasks and Notes.
     Loaded: loaded (/etc/systemd/system/etesync.service; disabled; vendor preset: enabled)
     Active: active (running) since Fri 2021-07-09 05:45:45 UTC; 5s ago
   Main PID: 16213 (daphne)
      Tasks: 1 (limit: 2353)
     Memory: 48.7M
     CGroup: /system.slice/etesync.service
             ??16213 /root/etesync/.venv/bin/python /root/etesync/.venv/bin/daphne -b 127.0.0.1 -p 8001 -u /tmp/etebase_server.sock etebase_se>

Jul 09 05:45:45 node1 systemd[1]: Started EteSync: End-to-End Encryption to Sync Calender, Contacts, Tasks and Notes..
Jul 09 05:45:46 node1 daphne[16213]: 2021-07-09 05:45:46,993 INFO     Starting server at tcp:port=8001:interface=127.0.0.1, unix:/tmp/etebase_>
Jul 09 05:45:46 node1 daphne[16213]: 2021-07-09 05:45:46,995 INFO     HTTP/2 support not enabled (install the http2 and tls Twisted extras)
Jul 09 05:45:46 node1 daphne[16213]: 2021-07-09 05:45:46,995 INFO     Configuring endpoint tcp:port=8001:interface=127.0.0.1
Jul 09 05:45:46 node1 daphne[16213]: 2021-07-09 05:45:46,997 INFO     Listening on TCP address 127.0.0.1:8001
Jul 09 05:45:46 node1 daphne[16213]: 2021-07-09 05:45:46,998 INFO     Configuring endpoint unix:/tmp/etebase_server.sock

A questo punto, EteSync è avviato e in ascolto sulla porta 8001. Ora puoi procedere al passaggio successivo.

Configurazione di Apache come proxy inverso

Si consiglia inoltre di installare e utilizzare Apache come proxy inverso per accedere a EteSync. Innanzitutto, installa il server Apache con il seguente comando:

apt-get install apache2 -y

Dopo aver installato il server Apache, abilita tutti i moduli proxy con il seguente comando:

a2enmod proxy proxy_http headers proxy_wstunnel

Successivamente, crea un nuovo file di configurazione dell'host virtuale Apache:

nano /etc/apache2/sites-available/etesync.conf

Aggiungi le seguenti righe:

<VirtualHost *:80>
   ServerName etesync.example.com
   ErrorDocument 404 /404.html

   ErrorLog ${APACHE_LOG_DIR}/etebase_error.log
   CustomLog ${APACHE_LOG_DIR}/etebase_access.log combined

   ProxyPreserveHost On
   ProxyPass / http://127.0.0.1:8001/
   ProxyPassReverse / http://127.0.0.1:8001/
   Alias /static /etesync/static

</VirtualHost>

Salvare e chiudere il file quindi attivare l'host virtuale Apache con il seguente comando:

a2ensite etesync.conf

Successivamente, riavvia Apache per aggiornare le modifiche:

systemctl restart apache2

Ora puoi verificare lo stato di Apache usando il seguente comando:

systemctl status apache2

Dovresti ottenere il seguente output:

? apache2.service - The Apache HTTP Server
     Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
     Active: active (running) since Fri 2021-07-09 05:50:26 UTC; 5s ago
       Docs: https://httpd.apache.org/docs/2.4/
    Process: 17551 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
   Main PID: 17567 (apache2)
      Tasks: 55 (limit: 2353)
     Memory: 5.3M
     CGroup: /system.slice/apache2.service
             ??17567 /usr/sbin/apache2 -k start
             ??17568 /usr/sbin/apache2 -k start
             ??17569 /usr/sbin/apache2 -k start

Jul 09 05:50:26 node1 systemd[1]: Starting The Apache HTTP Server...
Jul 09 05:50:26 node1 apachectl[17558]: AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 45.58.3>

Accedi alla console di amministrazione di EteSync

Ora apri il tuo browser web e accedi all'interfaccia di amministrazione di EteSync utilizzando l'URL http://etesync.example.com/admin/. Verrai reindirizzato alla seguente pagina:

Fornisci il nome utente e la password dell'amministratore e fai clic sul pulsante Accedi. Dovresti vedere la seguente pagina:

Proteggi EteSync con Lets Encrypt SSL

Innanzitutto, dovrai installare il client Certbot Lets Encrypt per scaricare e installare il certificato SSL per il tuo dominio.

Puoi installarlo con il seguente comando:

apt-get install python3-certbot-apache -y

Una volta installato, puoi eseguire il seguente comando per installare il certificato Lets Encrypt per il tuo dominio etesync.example.com.

certbot --apache -d etesync.example.com

Durante l'installazione, ti verrà chiesto di fornire il tuo indirizzo email e di accettare i termini di servizio come mostrato di seguito:

Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator apache, Installer apache
Enter email address (used for urgent renewal and security notices) (Enter 'c' to
cancel): 

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must
agree in order to register with the ACME server at
https://acme-v02.api.letsencrypt.org/directory
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(A)gree/(C)ancel: A

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing to share your email address with the Electronic Frontier
Foundation, a founding partner of the Let's Encrypt project and the non-profit
organization that develops Certbot? We'd like to send you email about our work
encrypting the web, EFF news, campaigns, and ways to support digital freedom.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: Y
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for etesync.example.com
Enabled Apache rewrite module
Waiting for verification...
Cleaning up challenges
Created an SSL vhost at /etc/apache2/sites-available/etesync-le-ssl.conf
Deploying Certificate to VirtualHost /etc/apache2/sites-available/etesync-le-ssl.conf
Enabling available site: /etc/apache2/sites-available/etesync-le-ssl.conf

Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: No redirect - Make no further changes to the webserver configuration.
2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for
new sites, or if you're confident your site works on HTTPS. You can undo this
change by editing your web server's configuration.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2

Successivamente, digita 2 e premi Invio per scaricare e installare un certificato SSL gratuito per il tuo dominio. Una volta che l'installazione è stata completata con successo. Dovresti ottenere il seguente output:

Enabled Apache rewrite module
Redirecting vhost in /etc/apache2/sites-enabled/etesync.conf to ssl vhost in /etc/apache2/sites-available/
etesync-le-ssl.conf

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations! You have successfully enabled https://etesync.example.com

You should test your configuration at:
https://www.ssllabs.com/ssltest/analyze.html?d=etesync.example.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Conclusione

Congratulazioni! hai installato correttamente EteSync sul server Ubuntu 20.04 con Lets Encrypt SSL. Ora puoi sincronizzare facilmente il tuo calendario e i tuoi contatti con EteSync.