Mattermost is an open-source messaging platform designed for team collaboration and communication. It is a great alternative to proprietary messaging systems and gives you full control over your data. In this guide, we will show you how to install Mattermost on Debian 11. Whether you're deploying Mattermost on a local server or a Windows VPS UK, these steps will help you set up Mattermost for efficient team communication.
Step 1: Update Your System
Before installing any software, it's a good idea to ensure that your system is up to date. Run the following commands to update your Debian 11 system:
sudo apt update && sudo apt upgrade -y
Keeping your system updated is critical for security and performance, especially when running it on a VPS Windows Servers platform.
Step 2: Install PostgreSQL
Mattermost requires a database to store its data. We will use PostgreSQL, which is supported by Mattermost. Install PostgreSQL with the following command:
sudo apt install postgresql postgresql-contrib -y
After installing PostgreSQL, start and enable it:
sudo systemctl start postgresql
sudo systemctl enable postgresql
Log into PostgreSQL and create a user and database for Mattermost:
sudo -u postgres psql
CREATE DATABASE mattermostdb;
CREATE USER mmuser WITH PASSWORD 'your_password';
GRANT ALL PRIVILEGES ON DATABASE mattermostdb TO mmuser;
\q
Replace your_password
with a strong password of your choice.
Step 3: Download and Install Mattermost
Download the latest version of Mattermost for Linux. Navigate to the /opt
directory and download Mattermost:
cd /opt
sudo wget https://releases.mattermost.com/7.0.0/mattermost-7.0.0-linux-amd64.tar.gz
Extract the Mattermost archive:
sudo tar -xvzf mattermost-7.0.0-linux-amd64.tar.gz
Move the extracted files to a directory and create a data folder:
sudo mv mattermost /opt/mattermost
sudo mkdir /opt/mattermost/data
Step 4: Configure Mattermost
Now configure Mattermost to connect to the PostgreSQL database. Open the configuration file:
sudo nano /opt/mattermost/config/config.json
Look for the following lines and update them with your PostgreSQL database information:
"DriverName": "postgres",
"DataSource": "postgres://mmuser:your_password@localhost:5432/mattermostdb?sslmode=disable&connect_timeout=10"
Replace your_password
with the password you set for the PostgreSQL user.
Save and close the file.
Step 5: Create a Mattermost Service
To manage Mattermost as a service, create a systemd service file. This will ensure Mattermost starts automatically with the system:
sudo nano /lib/systemd/system/mattermost.service
Add the following content to the service file:
[Unit]
Description=Mattermost
After=network.target
[Service]
Type=simple
User=mattermost
Group=mattermost
ExecStart=/opt/mattermost/bin/mattermost
Restart=always
RestartSec=10
WorkingDirectory=/opt/mattermost
[Install]
WantedBy=multi-user.target
Save and exit the file. Reload systemd and start the Mattermost service:
sudo systemctl daemon-reload
sudo systemctl start mattermost
sudo systemctl enable mattermost
Step 6: Configure Nginx as a Reverse Proxy (Optional)
In production environments, it’s recommended to use Nginx as a reverse proxy for Mattermost. Install Nginx:
sudo apt install nginx -y
Create a new Nginx configuration file for Mattermost:
sudo nano /etc/nginx/sites-available/mattermost
Add the following configuration:
server {
listen 80;
server_name yourdomain.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;
}
}
Enable the configuration and restart Nginx:
sudo ln -s /etc/nginx/sites-available/mattermost /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl restart nginx
Step 7: Access Mattermost
You can now access Mattermost by opening your web browser and navigating to http://yourdomain.com
. You will see the Mattermost setup page where you can create an admin account and configure your team.