GNU/Linux >> Linux Esercitazione >  >> Ubuntu

Come installare il sistema di messaggistica del team Mattermost su Ubuntu 20.04

Mattermost è un'applicazione di messaggistica open source e self-hosted utilizzata per chat, condivisione di file, ricerca e integrazioni. È un'alternativa alla chat Slack che riunisce tutte le comunicazioni del tuo team in un unico posto. È scritto in React e Golang e utilizza il database PostgreSQL o MySQL nel backend. Offre un ricco set di funzionalità tra cui Notifiche push, Cronologia di ricerca illimitata, Emoji personalizzati, Webhook e comandi, Active Directory, Supporto per l'implementazione di database multinodo, Forum, Discussion Board e molti altri.

In questo tutorial, ti mostreremo come installare Mattermost con Nginx e Let's Encrypt SSL su Ubuntu 20.04.

Prerequisiti

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

Per iniziare

Innanzitutto, si consiglia di aggiornare i pacchetti di sistema con l'ultima versione. Puoi aggiornarli eseguendo il seguente comando:

apt-get update -y

Una volta aggiornati tutti i pacchetti, installa le altre dipendenze richieste eseguendo il comando seguente:

apt-get install curl wget vim git unzip gnupg2 -y

Dopo aver installato tutti i pacchetti richiesti, puoi procedere al passaggio successivo.

Installa e configura MariaDB

Mattermost utilizza MySQL/MariaDB come backend di database. Quindi il server MariaDB deve essere installato nel tuo server. Se non è installato, puoi installarlo con il seguente comando:

apt-get install mariadb-server -y

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

mysql

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

MariaDB [(none)]> CREATE DATABASE mattermostdb;
MariaDB [(none)]> CREATE USER 'mattermost'@'%' IDENTIFIED BY 'password';

Quindi, concedi tutti i privilegi a Mattermost con il seguente comando:

MariaDB [(none)]> GRANT ALL PRIVILEGES ON mattermostdb.* TO 'mattermost'@'%';

Quindi, svuota i privilegi ed esci dalla shell MariaDB con il seguente comando:

MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> EXIT;

Una volta configurato il database MariaDB, puoi procedere al passaggio successivo.

Installa e configura Mattermost

Innanzitutto, dovrai scaricare l'ultima versione di Mattermost dal suo sito Web ufficiale. Puoi scaricarlo con il seguente comando:

wget https://releases.mattermost.com/5.24.2/mattermost-5.24.2-linux-amd64.tar.gz

Una volta scaricato, estrai il file scaricato con il seguente comando:

tar -xvzf mattermost-5.24.2-linux-amd64.tar.gz

Quindi, copia la directory estratta in /opt:

cp -r mattermost /opt

Quindi, crea una directory di dati per Mattermost:

mkdir /opt/mattermost/data

Successivamente, dovrai creare un utente separato per eseguire Mattermost. Puoi crearlo con il seguente comando:

useradd --system --user-group mattermost

Quindi, cambia la proprietà della directory mattermost in mattermost e concedi le autorizzazioni appropriate con il comando seguente:

chown -R mattermost:mattermost /opt/mattermost
chmod -R g+w /opt/mattermost

Quindi, modifica il file di configurazione predefinito Mattermost e definisci le impostazioni del database e l'URL del sito.

nano /opt/mattermost/config/config.json

Modifica le seguenti righe secondo le tue necessità:

    "SiteURL": "https://mattermost.linuxbuz.com",

    "DriverName": "mysql",
    "DataSource": "mattermost:[email protected](localhost:3306)/mattermostdb?charset=utf8mb4,utf8\u0026readTimeout=30s\u0026writeTimeout=30s",

Salva e chiudi il file quando hai finito.

Crea un file di servizio Systemd per Mattermost

Successivamente, dovrai creare un file di servizio systemd per gestire il servizio Mattermost. Puoi crearlo con il seguente comando:

nano /lib/systemd/system/mattermost.service

Aggiungi le seguenti righe:

[Unit]
Description=Mattermost
After=network.target
After=mysql.service
Requires=mysql.service

[Service]
Type=notify
User=mattermost
Group=mattermost
ExecStart=/opt/mattermost/bin/mattermost
TimeoutStartSec=3600
Restart=always
RestartSec=10
WorkingDirectory=/opt/mattermost
LimitNOFILE=49152

[Install]
WantedBy=mariadb.service

Salva e chiudi il file, quindi ricarica il demone systemd con il seguente comando:

systemctl daemon-reload

Quindi, avvia il servizio Mattermost e abilitalo all'avvio al riavvio del sistema con il seguente comando:

systemctl start mattermost
systemctl enable mattermost

Successivamente, verifica lo stato del servizio Mattermost con il seguente comando:

systemctl status mattermost

Dovresti ottenere il seguente output:

? mattermost.service - Mattermost
     Loaded: loaded (/lib/systemd/system/mattermost.service; disabled; vendor preset: enabled)
     Active: active (running) since Sat 2020-08-01 09:12:52 UTC; 17s ago
   Main PID: 4106 (mattermost)
      Tasks: 20 (limit: 2353)
     Memory: 85.9M
     CGroup: /system.slice/mattermost.service
             ??4106 /opt/mattermost/bin/mattermost
             ??4198 plugins/com.mattermost.nps/server/dist/plugin-linux-amd64

Aug 01 09:12:52 ubuntu2004 mattermost[4106]: {"level":"info","ts":1596273172.131499,"caller":"mlog/sugar.go:19","msg":"Sent notification of ne>
Aug 01 09:12:52 ubuntu2004 mattermost[4106]: {"level":"info","ts":1596273172.1841655,"caller":"jobs/workers.go:73","msg":"Starting workers"}
Aug 01 09:12:52 ubuntu2004 mattermost[4106]: {"level":"info","ts":1596273172.1842792,"caller":"bleveengine/bleve.go:267","msg":"UpdateConf Ble>
Aug 01 09:12:52 ubuntu2004 mattermost[4106]: {"level":"info","ts":1596273172.1930475,"caller":"jobs/schedulers.go:74","msg":"Starting schedule>
Aug 01 09:12:52 ubuntu2004 mattermost[4106]: {"level":"info","ts":1596273172.20063,"caller":"app/web_hub.go:83","msg":"Starting websocket hubs>
Aug 01 09:12:52 ubuntu2004 mattermost[4106]: {"level":"info","ts":1596273172.2099638,"caller":"app/license.go:37","msg":"License key from http>
Aug 01 09:12:52 ubuntu2004 mattermost[4106]: {"level":"info","ts":1596273172.2205582,"caller":"app/server.go:525","msg":"Starting Server..."}
Aug 01 09:12:52 ubuntu2004 mattermost[4106]: {"level":"info","ts":1596273172.2208374,"caller":"app/server.go:594","msg":"Server is listening o>
Aug 01 09:12:52 ubuntu2004 mattermost[4106]: {"level":"info","ts":1596273172.2211802,"caller":"commands/server.go:106","msg":"Sending systemd >
Aug 01 09:12:52 ubuntu2004 systemd[1]: Started Mattermost.

A questo punto, Mattermost è in esecuzione e in ascolto sulla porta 8065.

Configura Nginx come proxy inverso

Successivamente, dovrai configurare Nginxx come proxy inverso per Mattermost. Innanzitutto, installa il pacchetto Nginx con il seguente comando:

apt-get install nginx -y

Una volta installato, crea un file di configurazione dell'host virtuale Nginx con il seguente comando:

nano /etc/nginx/sites-available/mattermost.conf

Aggiungi le seguenti righe:

upstream mattermost {
   server localhost:8065;
   keepalive 32;
}

proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=mattermost_cache:10m max_size=3g inactive=120m use_temp_path=off;

server {
   listen 80;
   server_name mattermost.linuxbuz.com;

   location ~ /api/v[0-9]+/(users/)?websocket$ {
       proxy_set_header Upgrade $http_upgrade;
       proxy_set_header Connection "upgrade";
       client_max_body_size 50M;
       proxy_set_header Host $http_host;
       proxy_set_header X-Real-IP $remote_addr;
       proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
       proxy_set_header X-Forwarded-Proto $scheme;
       proxy_set_header X-Frame-Options SAMEORIGIN;
       proxy_buffers 256 16k;
       proxy_buffer_size 16k;
       client_body_timeout 60;
       send_timeout 300;
       lingering_timeout 5;
       proxy_connect_timeout 90;
       proxy_send_timeout 300;
       proxy_read_timeout 90s;
       proxy_pass http://mattermost;
   }

   location / {
       client_max_body_size 50M;
       proxy_set_header Connection "";
       proxy_set_header Host $http_host;
       proxy_set_header X-Real-IP $remote_addr;
       proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
       proxy_set_header X-Forwarded-Proto $scheme;
       proxy_set_header X-Frame-Options SAMEORIGIN;
       proxy_buffers 256 16k;
       proxy_buffer_size 16k;
       proxy_read_timeout 600s;
       proxy_cache mattermost_cache;
       proxy_cache_revalidate on;
       proxy_cache_min_uses 2;
       proxy_cache_use_stale timeout;
       proxy_cache_lock on;
       proxy_http_version 1.1;
       proxy_pass http://mattermost;
   }
}

Salva e chiudi il file quindi attiva la configurazione dell'host virtuale con il seguente comando:

ln -s /etc/nginx/sites-available/mattermost.conf /etc/nginx/sites-enabled/mattermost.conf

Quindi, verifica Nginx per eventuali errori di configurazione:

nginx -t

Dovresti ottenere il seguente output:

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

Infine, riavvia il servizio Nginx per applicare le modifiche:

systemctl restart nginx

Secure Mattermost con Let's Encrypt SSL

Innanzitutto, dovrai installare il client Certbot nel tuo sistema per gestire Let's Encrypt SSL. Puoi installarlo con il seguente comando:

apt-get install python3-certbot-nginx -y

Dopo aver installato Certbot, esegui il comando seguente per installare Let's Encrypt SSL per il tuo sito web.

certbot --nginx -d mattermost.linuxbuz.com

Ti verrà chiesto di fornire un indirizzo email valido e di accettare i termini del servizio come mostrato di seguito:

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

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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 mattermost.linuxbuz.com
Waiting for verification...
Cleaning up challenges
Deploying Certificate to VirtualHost /etc/nginx/sites-enabled/mattermost.conf

Quindi, seleziona se reindirizzare o meno il traffico HTTP su HTTPS:

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

Digita 2 e premi Invio per installare Let's Encrypt SSL sul tuo dominio. Una volta installato, dovresti vedere il seguente output:

Redirecting all traffic on port 80 to ssl in /etc/nginx/sites-enabled/mattermost.conf

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations! You have successfully enabled https://mattermost.linuxbuz.com

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

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/mattermost.linuxbuz.com/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/mattermost.linuxbuz.com/privkey.pem
   Your cert will expire on 2020-10-30. To obtain a new or tweaked
   version of this certificate in the future, simply run certbot again
   with the "certonly" option. To non-interactively renew *all* of
   your certificates, run "certbot renew"
 - Your account credentials have been saved in your Certbot
   configuration directory at /etc/letsencrypt. You should make a
   secure backup of this folder now. This configuration directory will
   also contain certificates and private keys obtained by Certbot so
   making regular backups of this folder is ideal.
 - If you like Certbot, please consider supporting our work by:

   Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
   Donating to EFF:                    https://eff.org/donate-le

 - We were unable to subscribe you the EFF mailing list because your
   e-mail address appears to be invalid. You can try again later by
   visiting https://act.eff.org.

Accedi all'interfaccia Web di Mattermost

Ora apri il tuo browser web e digita l'URL https://mattermost.linuxbuz.com. Verrai reindirizzato alla schermata di registrazione di Mattermost:

Fornisci il tuo indirizzo email, nome, password e fai clic su Crea account pulsante. Dovresti vedere la seguente schermata:

Fai clic su Crea un squadra pulsante. Dovresti vedere la seguente schermata:

Fornisci il nome della tua squadra e fai clic su Avanti pulsante. Dovresti vedere la seguente schermata:

Fornisci l'URL del tuo team e fai clic su Fine pulsante. Dovresti vedere la schermata di benvenuto di Mattermost:

Fai clic su Salta Tutorial pulsante. Dovresti vedere la dashboard Mattermost nella schermata seguente:

Conclusione

In questa guida, hai imparato come installare l'applicazione Mattermost Team Messaging sul server Ubuntu 20.04. Hai anche imparato come configurare Nginx come proxy inverso e proteggerlo con Let's Encrypt SSL. Ora puoi esplorare i servizi Mattermost e collaborare con il tuo team.


Ubuntu
  1. Come installare OpenProject su Ubuntu 16.04

  2. Come installare Logstash su Ubuntu 18.04

  3. Come installare il sistema di messaggistica del team Mattermost su Debian 10

  4. Come installare Gradle su Ubuntu 18.04

  5. Come installare Elasticsearch su Ubuntu 20.04

Come installare Ferdi Messaging Suite su Ubuntu 20.10 Edition

Come installare Lynis su Ubuntu 20.04

Come installare XAMPP sul tuo sistema Ubuntu 20.04 LTS

Come installare urBackup su Ubuntu 20.04

Come installare Dropbox su Ubuntu 18.04 e 16.04

Come installare AnyDesk su Ubuntu 20.04