Installazione software · 9 min read · Oct 12, 2025
Come installare il sistema di messaggistica Mattermost Team su Ubuntu 20.04

Mattermost è un’applicazione di messaggistica open-source e auto-ospitata utilizzata per chat, condivisione di file, ricerca e integrazioni. È un’alternativa alla chat di Slack che riunisce tutta la comunicazione del tuo team in un unico posto. È scritta in React e Golang, e utilizza PostgreSQL o MySQL come database nel backend. Offre un ricco set di funzionalità tra cui Notifiche Push, Cronologia di ricerca illimitata, Emoji personalizzati, Webhook e comandi, Directory attiva, Supporto per distribuzione di database multi-nodo, Forum, Bacheca di discussione e molto altro.
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.
- Una password di root configurata sul server.
Iniziare
Prima di tutto, è consigliato aggiornare i pacchetti del sistema all’ultima versione. Puoi aggiornarli eseguendo il seguente comando:
apt-get update -yUna volta aggiornati tutti i pacchetti, installa altre dipendenze richieste eseguendo il seguente comando:
apt-get install curl wget vim git unzip gnupg2 -yDopo aver installato tutti i pacchetti richiesti, puoi procedere al passaggio successivo.
Installa e configura MariaDB
Mattermost utilizza MySQL/MariaDB come backend del database. Quindi, il server MariaDB deve essere installato sul tuo server. Se non è installato, puoi installarlo con il seguente comando:
apt-get install mariadb-server -yDopo aver installato il server MariaDB, accedi a MariaDB con il seguente comando:
mysqlUna 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';Successivamente, concedi tutti i privilegi a Mattermost con il seguente comando:
MariaDB [(none)]> GRANT ALL PRIVILEGES ON mattermostdb.* TO 'mattermost'@'%';Successivamente, svuota i privilegi e esci dalla shell di 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
Prima di tutto, dovrai scaricare l’ultima versione di Mattermost dal suo sito ufficiale. Puoi scaricarlo con il seguente comando:
wget https://releases.mattermost.com/5.24.2/mattermost-5.24.2-linux-amd64.tar.gzUna volta scaricato, estrai il file scaricato con il seguente comando:
tar -xvzf mattermost-5.24.2-linux-amd64.tar.gzSuccessivamente, copia la directory estratta in /opt:
cp -r mattermost /optSuccessivamente, crea una directory dati per Mattermost:
mkdir /opt/mattermost/dataSuccessivamente, dovrai creare un utente separato per eseguire Mattermost. Puoi crearlo con il seguente comando:
useradd --system --user-group mattermostSuccessivamente, cambia la proprietà della directory mattermost in mattermost e dai i permessi appropriati con il seguente comando:
chown -R mattermost:mattermost /opt/mattermost
chmod -R g+w /opt/mattermostSuccessivamente, modifica il file di configurazione predefinito di Mattermost e definisci le impostazioni del tuo database e l’URL del sito.
nano /opt/mattermost/config/config.jsonCambia le seguenti righe in base alle tue esigenze:
"SiteURL": "https://mattermost.linuxbuz.com",
"DriverName": "mysql",
"DataSource": "mattermost:password@tcp(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.serviceAggiungi 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.serviceSalva e chiudi il file, quindi ricarica il demone systemd con il seguente comando:
systemctl daemon-reloadSuccessivamente, avvia il servizio Mattermost e abilitalo per avviarsi al riavvio del sistema con il seguente comando:
systemctl start mattermost
systemctl enable mattermostSuccessivamente, verifica lo stato del servizio Mattermost con il seguente comando:
systemctl status mattermostDovresti 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 reverse proxy
Successivamente, dovrai configurare Nginx come reverse proxy per Mattermost. Prima di tutto, installa il pacchetto Nginx con il seguente comando:
apt-get install nginx -yUna volta installato, crea un file di configurazione del virtual host Nginx con il seguente comando:
nano /etc/nginx/sites-available/mattermost.confAggiungi 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 del virtual host con il seguente comando:
ln -s /etc/nginx/sites-available/mattermost.conf /etc/nginx/sites-enabled/mattermost.confSuccessivamente, verifica la configurazione di Nginx per eventuali errori:
ginx -tDovresti ottenere il seguente output:
ginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successfulInfine, riavvia il servizio Nginx per applicare le modifiche:
systemctl restart nginxSicurezza di Mattermost con Let’s Encrypt SSL
Prima di tutto, dovrai installare il client Certbot nel tuo sistema per gestire il Let’s Encrypt SSL. Puoi installarlo con il seguente comando:
apt-get install python3-certbot-nginx -yDopo aver installato Certbot, esegui il seguente comando per installare il Let’s Encrypt SSL per il tuo sito web.
certbot --nginx -d mattermost.linuxbuz.comTi verrà chiesto di fornire un indirizzo email valido e accettare i termini di 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.confSuccessivamente, seleziona se reindirizzare o meno il traffico HTTP a 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): 2Digita 2 e premi Invio per installare il 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 sul pulsante Crea account. Dovresti vedere la seguente schermata:

Fai clic sul pulsante Crea un team. Dovresti vedere la seguente schermata:

Fornisci il nome del tuo team e fai clic sul pulsante Avanti. Dovresti vedere la seguente schermata:

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

Fai clic sul pulsante Salta tutorial. Dovresti vedere il dashboard di Mattermost nella seguente schermata:

Conclusione
In questa guida, hai imparato come installare l’applicazione di messaggistica Mattermost Team su un server Ubuntu 20.04. Hai anche imparato come configurare Nginx come reverse proxy e proteggerlo con Let’s Encrypt SSL. Ora puoi esplorare i servizi di Mattermost e lavorare insieme al tuo team.
Ricevi i nuovi post nella tua casella di posta.
Nessuno spam. Disiscriviti in qualsiasi momento.