GNU/Linux >> Tutoriales Linux >  >> Ubuntu

Cómo instalar el sistema de mensajería de Mattermost Team en Ubuntu 20.04

Mattermost es una aplicación de mensajería de código abierto y autohospedada que se utiliza para chatear, compartir archivos, buscar e integraciones. Es una alternativa al chat de Slack que reúne toda la comunicación de su equipo en un solo lugar. Está escrito en React y Golang, y utiliza una base de datos PostgreSQL o MySQL en el backend. Ofrece un amplio conjunto de características que incluyen notificaciones automáticas, historial de búsqueda ilimitado, emojis personalizados, webhooks y comandos, directorio activo, compatibilidad con la implementación de bases de datos de múltiples nodos, foro, tablero de discusión y muchas más.

En este tutorial, le mostraremos cómo instalar Mattermost con Nginx y Let's Encrypt SSL en Ubuntu 20.04.

Requisitos

  • Un servidor con Ubuntu 20.04.
  • Un nombre de dominio válido apuntado con la IP de su servidor.
  • Se configura una contraseña raíz en el servidor.

Cómo empezar

Primero, se recomienda actualizar los paquetes de su sistema con la última versión. Puede actualizarlos ejecutando el siguiente comando:

apt-get update -y

Una vez que todos los paquetes estén actualizados, instale otras dependencias requeridas ejecutando el siguiente comando:

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

Después de instalar todos los paquetes necesarios, puede continuar con el siguiente paso.

Instalar y configurar MariaDB

Mattermost utiliza MySQL/MariaDB como base de datos. Entonces el servidor MariaDB debe estar instalado en su servidor. Si no está instalado, puede instalarlo con el siguiente comando:

apt-get install mariadb-server -y

Después de instalar el servidor MariaDB, inicie sesión en MariaDB con el siguiente comando:

mysql

Una vez que inicie sesión, cree una base de datos y un usuario para Mattermost con el siguiente comando:

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

A continuación, otorgue todos los privilegios al Mattermost con el siguiente comando:

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

A continuación, elimine los privilegios y salga del shell de MariaDB con el siguiente comando:

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

Una vez que su base de datos MariaDB esté configurada, puede continuar con el siguiente paso.

Instalar y configurar Mattermost

Primero, deberá descargar la última versión de Mattermost desde su sitio web oficial. Puedes descargarlo con el siguiente comando:

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

Una vez descargado, extraiga el archivo descargado con el siguiente comando:

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

A continuación, copie el directorio extraído en /opt:

cp -r mattermost /opt

A continuación, cree un directorio de datos para Mattermost:

mkdir /opt/mattermost/data

A continuación, deberá crear un usuario separado para ejecutar Mattermost. Puedes crearlo con el siguiente comando:

useradd --system --user-group mattermost

A continuación, cambie la propiedad del directorio mattermost a mattermost y otorgue los permisos adecuados con el siguiente comando:

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

A continuación, edite el archivo de configuración predeterminado de Mattermost y defina la configuración de su base de datos y la URL del sitio.

nano /opt/mattermost/config/config.json

Cambie las siguientes líneas según su necesidad:

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

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

Guarde y cierre el archivo cuando haya terminado.

Crear un archivo de servicio de Systemd para Mattermost

A continuación, deberá crear un archivo de servicio systemd para administrar el servicio Mattermost. Puedes crearlo con el siguiente comando:

nano /lib/systemd/system/mattermost.service

Agregue las siguientes líneas:

[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

Guarde y cierre el archivo, luego vuelva a abrir el demonio systemd con el siguiente comando:

systemctl daemon-reload

A continuación, inicie el servicio Mattermost y habilítelo para que se inicie al reiniciar el sistema con el siguiente comando:

systemctl start mattermost
systemctl enable mattermost

A continuación, verifique el estado del servicio de Mattermost con el siguiente comando:

systemctl status mattermost

Deberías obtener el siguiente resultado:

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

En este punto, Mattermost se está ejecutando y escuchando en el puerto 8065.

Configurar Nginx como proxy inverso

A continuación, deberá configurar Nginxx como un proxy inverso para Mattermost. Primero, instale el paquete Nginx con el siguiente comando:

apt-get install nginx -y

Una vez instalado, cree un archivo de configuración de host virtual Nginx con el siguiente comando:

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

Agregue las siguientes líneas:

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

Guarde y cierre el archivo, luego active la configuración del host virtual con el siguiente comando:

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

Luego, verifique el Nginx para cualquier error de configuración:

nginx -t

Deberías obtener el siguiente resultado:

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

Finalmente, reinicie el servicio Nginx para aplicar los cambios:

systemctl restart nginx

Asegure Mattermost con Let's Encrypt SSL

Primero, deberá instalar el cliente Certbot en su sistema para administrar Let's Encrypt SSL. Puede instalarlo con el siguiente comando:

apt-get install python3-certbot-nginx -y

Después de instalar Certbot, ejecute el siguiente comando para instalar Let's Encrypt SSL para su sitio web.

certbot --nginx -d mattermost.linuxbuz.com

Se le pedirá que proporcione una dirección de correo electrónico válida y acepte el término de servicio como se muestra a continuación:

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

A continuación, seleccione si desea redirigir o no el tráfico 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): 2

Escriba 2 y presione Entrar para instalar Let's Encrypt SSL en su dominio. Una vez instalado, debería ver el siguiente resultado:

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.

Acceder a la interfaz web de Mattermost

Ahora, abra su navegador web y escriba la URL https://mattermost.linuxbuz.com. Será redirigido a la pantalla de registro de Mattermost:

Proporcione su dirección de correo electrónico, nombre, contraseña y haga clic en Crear cuenta botón. Debería ver la siguiente pantalla:

Haga clic en Crear un equipo botón. Debería ver la siguiente pantalla:

Proporcione el nombre de su equipo y haga clic en Siguiente botón. Debería ver la siguiente pantalla:

Proporcione la URL de su equipo y haga clic en Finalizar botón. Debería ver la pantalla de bienvenida de Mattermost:

Haga clic en Omitir Tutoriales botón. Debería ver el panel de control de Mattermost en la siguiente pantalla:

Conclusión

En esta guía, aprendió cómo instalar la aplicación Mattermost Team Messaging en el servidor Ubuntu 20.04. También aprendió cómo configurar Nginx como un proxy inverso y protegerlo con Let's Encrypt SSL. Ahora puede explorar los servicios de Mattermost y trabajar junto con su equipo.


Ubuntu
  1. Cómo instalar OpenProject en Ubuntu 16.04

  2. Cómo instalar Logstash en Ubuntu 18.04

  3. Cómo instalar el sistema de mensajería del equipo de Mattermost en Debian 10

  4. Cómo instalar Gradle en Ubuntu 18.04

  5. Cómo instalar Elasticsearch en Ubuntu 20.04

Cómo instalar Ferdi Messaging Suite en Ubuntu 20.10 Edition

Cómo instalar Lynis en Ubuntu 20.04

Cómo instalar XAMPP en su sistema Ubuntu 20.04 LTS

Cómo instalar urBackup en Ubuntu 20.04

Cómo instalar Dropbox en Ubuntu 18.04 y 16.04

Cómo instalar AnyDesk en Ubuntu 20.04