Mattermost Instaleation for Team Communication
Mattermost is an open-source, self-hosted team communication and collaboration platform designed as an alternative to Slack. With features like messaging, video conferencing, file sharing, and integrations with popular tools, Mattermost enables secure team communication while maintaining complete data ownership. This guide covers the complete installation process, including PostgreSQL database setup, Nginx configuration, SSL encryption, and team configuration.
Tabla de contenidos
- Prerequisites
- System Requirements
- PostgreSQL Instaleation
- Mattermost Instaleation
- Nginx Configuration
- SSL Certificate Setup
- Initial Configuration
- User and Team Management
- Integrations Setup
- Backup and Updates
- Troubleshooting
- Conclusion
Requisitos previos
Antes de la instalación, asegúrese de tener:
- Ubuntu 20.04 LTS or later
- Root or sudo access
- A valid domain name
- Minimum 4GB RAM (8GB recommended for production)
- 20GB available disk space
- Basic Linux administration knowledge
Actualice los paquetes del sistema:
sudo apt update && sudo apt upgrade -y
Requisitos del sistema
Verifique las especificaciones del sistema for Mattermost:
Check system architecture:
uname -m
cat /etc/os-release
Verifique available resources:
free -h
df -h
Instalación de PostgreSQL
Instale PostgreSQL database server:
sudo apt install -y postgresql postgresql-contrib
Inicie y habilite PostgreSQL:
sudo systemctl start postgresql
sudo systemctl enable postgresql
Verifique PostgreSQL status:
sudo systemctl status postgresql
Cree Mattermost database:
sudo -u postgres psql << EOF
CREATE DATABASE mattermost;
CREATE USER mattermost WITH PASSWORD 'SecurePassword123!';
GRANT ALL PRIVILEGES ON DATABASE mattermost TO mattermost;
ALTER DATABASE mattermost OWNER TO mattermost;
\q
EOF
Test database connection:
psql -h localhost -U mattermost -d mattermost
\l
\q
Mattermost Instaleation
Cree Mattermost installation directory:
sudo mkdir -p /opt/mattermost
cd /opt/mattermost
Descargue latest Mattermost release:
cd /tmp
wget https://releases.mattermost.com/mattermost-linux.tar.gz
tar -xzf mattermost-linux.tar.gz
sudo cp -r mattermost/* /opt/mattermost/
Cree data directory:
sudo mkdir -p /opt/mattermost/data
Cree Mattermost system user:
sudo useradd -r -s /bin/false -m -d /opt/mattermost mattermost
Establezca los permisos correctos:
sudo chown -R mattermost:mattermost /opt/mattermost
sudo chmod -R 755 /opt/mattermost
sudo chmod 700 /opt/mattermost/data
Configuración de Nginx
Instale Nginx:
sudo apt install -y nginx
Cree Nginx configuration for Mattermost:
sudo nano /etc/nginx/sites-available/mattermost
Add configuration:
upstream mattermost {
server localhost:8065 max_fails=5 fail_timeout=60s;
keepalive 32;
}
server {
listen 80;
listen [::]:80;
server_name example.com www.example.com;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name example.com www.example.com;
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
client_max_body_size 100M;
location / {
proxy_pass http://mattermost;
proxy_http_version 1.1;
proxy_buffering off;
proxy_request_buffering off;
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_read_timeout 600s;
proxy_send_timeout 600s;
}
location /api/v4/users/websocket {
proxy_pass http://mattermost;
proxy_http_version 1.1;
proxy_buffering off;
proxy_request_buffering off;
proxy_set_header Connection "Upgrade";
proxy_set_header Upgrade $http_upgrade;
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_read_timeout 6h;
proxy_send_timeout 6h;
}
}
Habilite el sitio:
sudo ln -s /etc/nginx/sites-available/mattermost /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl restart nginx
Start Nginx:
sudo systemctl start nginx
sudo systemctl enable nginx
Configuración del certificado SSL
Instale Certbot:
sudo apt install -y certbot python3-certbot-nginx
Obtain SSL certificate:
sudo certbot certonly --standalone -d example.com -d www.example.com
The Nginx configuration already references these certificates. Verifique certificate installation:
sudo openssl x509 -in /etc/letsencrypt/live/example.com/fullchain.pem -noout -dates
Configure automatic renewal:
sudo systemctl enable certbot.timer
sudo systemctl start certbot.timer
Configuración inicial
Edit Mattermost configuration file:
sudo nano /opt/mattermost/config/config.json
Update database settings:
"SqlSettings": {
"DriverName": "postgres",
"DataSource": "postgres://mattermost:SecurePassword123!@localhost:5432/mattermost?sslmode=disable&connect_timeout=10",
"MaxIdleConns": 20,
"MaxOpenConns": 300,
"Trace": false,
"AtRestEncryptKey": "generated-key-here",
"QueryTimeout": 30
}
Update service settings:
"ServiceSettings": {
"SiteURL": "https://example.com",
"WebsocketURL": "wss://example.com",
"LicenseFileLocation": "",
"ListenAddress": ":8065",
"ConnectionSecurity": "",
"TLSCertFile": "",
"TLSKeyFile": "",
"UseSSL": false,
"Forward80To443": false
}
Cree systemd service file:
sudo nano /etc/systemd/system/mattermost.service
Add:
[Unit]
Description=Mattermost
After=network.target postgresql.service
BindsTo=postgresql.service
[Service]
Type=simple
ExecStart=/opt/mattermost/bin/mattermost
TimeoutStartSec=3600s
Restart=always
RestartSec=10
WorkingDirectory=/opt/mattermost
User=mattermost
Group=mattermost
LimitNOFILE=49152
[Install]
WantedBy=multi-user.target
Enable and start Mattermost:
sudo systemctl daemon-reload
sudo systemctl enable mattermost
sudo systemctl start mattermost
Verifique Mattermost is running:
sudo systemctl status mattermost
Monitor logs:
sudo journalctl -u mattermost -f
Configuración inicial
Access Mattermost web interface:
Navigate to https://example.com and complete the setup wizard:
- Cree the system admin account
- Configure workspace settings
- Set the team name and display name
- Verifique email configuration
Gestión de usuarios y equipos
Cree additional users through the admin panel:
- System Console → User Management → Users
- Click "Invite User" to add new team members
- Configure user roles (Admin, Team Admin, User)
Cree additional teams:
- Workspace → Cree a Team
- Set team name, URL, and description
- Configure team privacy settings
Configure team channels:
- Cree channels for different topics
- Configure channel privacy (Public/Private)
- Invite team members to relevant channels
Configuración de integraciones
Configure SMTP for email notifications:
- System Console → Environment → SMTP
- Set SMTP server details
- Configure sender email and password
- Test email configuration
Enable OAuth authentication:
- System Console → Authentication → OAuth 2.0
- Configure Google, GitHub, or LDAP authentication
Instale slash commands for automation:
- System Console → Integrations → Slash Commands
- Cree custom commands for team workflows
Enable incoming webhooks:
- System Console → Integrations → Incoming Webhooks
- Cree webhooks for external service integration
Copia de seguridad y actualizaciones
Cree backup script:
sudo nano /usr/local/bin/mattermost-backup.sh
Add:
#!/bin/bash
BACKUP_DIR="/backups/mattermost"
MATTERMOST_DIR="/opt/mattermost"
DATE=$(date +%Y%m%d_%H%M%S)
mkdir -p $BACKUP_DIR
# Stop Mattermost
sudo systemctl stop mattermost
# Database backup
pg_dump -U mattermost mattermost | gzip > "$BACKUP_DIR/mattermost-db-$DATE.sql.gz"
# Files backup
tar -czf "$BACKUP_DIR/mattermost-config-$DATE.tar.gz" "$MATTERMOST_DIR/config"
tar -czf "$BACKUP_DIR/mattermost-data-$DATE.tar.gz" "$MATTERMOST_DIR/data"
# Start Mattermost
sudo systemctl start mattermost
# Keep only 30 days of backups
find $BACKUP_DIR -type f -mtime +30 -delete
echo "Backup completed: $DATE"
Make executable:
sudo chmod +x /usr/local/bin/mattermost-backup.sh
Schedule daily backups:
sudo crontab -e
Add:
0 2 * * * /usr/local/bin/mattermost-backup.sh >> /var/log/mattermost-backup.log 2>&1
Update Mattermost:
sudo systemctl stop mattermost
cd /opt/mattermost
wget https://releases.mattermost.com/mattermost-linux.tar.gz
tar -xzf mattermost-linux.tar.gz
sudo chown -R mattermost:mattermost /opt/mattermost
sudo systemctl start mattermost
Solución de problemas
Check Mattermost status:
sudo systemctl status mattermost
View error logs:
sudo journalctl -u mattermost -n 50
Verifique database connectivity:
psql -h localhost -U mattermost -d mattermost
\dt
\q
Check Nginx configuration:
sudo nginx -t
sudo systemctl status nginx
Reinicie services if needed:
sudo systemctl restart mattermost
sudo systemctl restart nginx
Conclusión
Mattermost is now fully installed and configured as a team communication platform. With PostgreSQL database, Nginx reverse proxy, SSL encryption, and proper integrations, you have a secure, self-hosted alternative to commercial messaging platforms. Regular backups and updates ensure system reliability and security. Configure teams, channels, and integrations to create a productive team workspace.


