Mattermost is an open-source, self-hosted messaging platform designed for team collaboration. It is a great alternative to Slack and is widely used for secure communication. This guide will walk you through installing Mattermost on Ubuntu, Debian, AlmaLinux, and Rocky Linux.
Prerequisites
Before installing Mattermost, ensure you have the following:
-
A server running Ubuntu 22.04/20.04, Debian 11/10, AlmaLinux 9/8, or Rocky Linux 9/8.
-
Root or sudo access.
-
A PostgreSQL database.
-
At least 4GB of RAM and 2 CPUs.
Step 1: Update Your System
Update your package lists and upgrade installed packages:
sudo apt update && sudo apt upgrade -y # For Ubuntu/Debian
sudo dnf update -y # For AlmaLinux/Rocky
Step 2: Install Required Packages
Install PostgreSQL and other dependencies:
# For Ubuntu/Debian
sudo apt install postgresql postgresql-contrib wget -y
# For AlmaLinux/Rocky
sudo dnf install postgresql-server postgresql-contrib wget -y
Initialize and start PostgreSQL:
sudo systemctl enable --now postgresql
Create a database and user for Mattermost:
sudo -u postgres psql
CREATE DATABASE mattermost;
CREATE USER mmuser WITH PASSWORD 'secure_password';
GRANT ALL PRIVILEGES ON DATABASE mattermost TO mmuser;
\q
Step 3: Download and Set Up Mattermost
Navigate to the /opt directory and download Mattermost:
cd /opt
wget https://releases.mattermost.com/9.0/mattermost-9.0-linux-amd64.tar.gz
sudo tar -xvzf mattermost-9.0-linux-amd64.tar.gz
sudo mv mattermost /opt/mattermost
Create a storage directory:
sudo mkdir /opt/mattermost/data
Set correct permissions:
sudo chown -R mattermost:mattermost /opt/mattermost
sudo chmod -R 755 /opt/mattermost
Step 4: Configure Mattermost
Edit the configuration file:
sudo nano /opt/mattermost/config/config.json
Modify the database settings:
"DriverName": "postgres",
"DataSource": "postgres://mmuser:secure_password@localhost/mattermost?sslmode=disable",
Save and exit.
Step 5: Create a Systemd Service
Create a new service file:
sudo nano /etc/systemd/system/mattermost.service
Add the following content:
[Unit]
Description=Mattermost
After=network.target postgresql.service
[Service]
Type=simple
ExecStart=/opt/mattermost/bin/mattermost
WorkingDirectory=/opt/mattermost
User=mattermost
Group=mattermost
Restart=always
RestartSec=10
LimitNOFILE=49152
[Install]
WantedBy=multi-user.target
Enable and start Mattermost:
sudo systemctl daemon-reload
sudo systemctl enable --now mattermost
Step 6: Configure Reverse Proxy with Nginx
Install Nginx:
sudo apt install nginx -y # Ubuntu/Debian
sudo dnf install nginx -y # AlmaLinux/Rocky
Create a new Nginx configuration file:
sudo nano /etc/nginx/conf.d/mattermost.conf
Add the following content:
server {
listen 80;
server_name your-domain.com;
location / {
proxy_pass http://localhost:8065/;
proxy_set_header Host $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;
}
}
Restart Nginx:
sudo systemctl restart nginx
Step 7: Finalize Mattermost Setup
-
Open your browser and visit
http://your-domain.com
. -
Create an admin account and configure your workspace.
-
Start using Mattermost!
Conclusion
You have successfully installed Mattermost on Ubuntu, Debian, AlmaLinux, or Rocky Linux. To enhance security, enable SSL with Let’s Encrypt and configure a firewall.