How To'sLinux

How To Install Mattermost on Debian 11 Bullseye

This guide will let you install Mattermost on Debian 11. For those who don’t know, Mattermost is a self-hosted, open-source online chat service designed for usage by businesses and organizations. It facilitates safe team communication and individual and group cooperation. Because Mattermost is cloud-based, developers may access data from anywhere and contribute directly to the source code.

This article assumes you know Linux, can use the shell, and most importantly, run your own VPS. For the installation to work, you must run as root or add ‘sudo’ to the command line to gain root privileges. I will guide you through the installation of Mattermost open-source developer collaboration platform on Debian 11 (Bullseye).

Install Mattermost on Debian 11 Bullseye

#1 Update

To ensure that your system is up to date before installing any new software, execute the following command to update:

sudo apt update
sudo apt upgrade

#2 Install The LEMP Stack

#3 Configuring MariaDB for Mattermost

MariaDB is not hardened by default. The mysql_secure_installation script secures MariaDB. Set a root password, remove anonymous users, disable remote root login, remove the test database, and secure MariaDB:


Configure it like that:

- Set root password? [Y/n] y
- Remove anonymous users? [Y/n] y
- Disallow root login remotely? [Y/n] y
- Remove test database and access to it? [Y/n] y
- Reload privilege tables now? [Y/n] y

Next, we’ll need to create a database for Mattermost via the MariaDB console. Execute the command:

mysql -u root -p

Enter your MariaDB root password and hit Enter. Once logged in to your database server, create a database for Mattermost:

MariaDB [(none)]> CREATE DATABASE db;
MariaDB [(none)]> CREATE USER 'user' IDENTIFIED BY 'yourpassword';
MariaDB [(none)]> GRANT ALL PRIVILEGES ON db.* TO 'user';
MariaDB [(none)]> EXIT;

#4 Installing Mattermost on Debian 11

Create a new user and group for our Mattermost server before installing:

sudo useradd --system --user-group mattermost

Mattermost is not included in the Debian 11 base repository. So, now we get Mattermost from the official website:


Afterwards, extract the file:

tar xvzf mattermost-6.0.2-linux-amd64.tar.gz -C /opt/
sudo mkdir /opt/mattermost/data

Change certain folder permissions:

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

#5 Configuring Mattermost

Now we need to configure Mattermost. Edit the Mattermost configuration file to set your site’s URL and database:

nano /opt/mattermost/config/config.json

Modify these lines:

"SiteURL": "", 
"DriverName": "MySQL", 
"DataSource": "mmuser:[email protected](localhost:3306)/mattermost?charset=utf8mb4,utf8&readTimeout=30s&writeTimeout=30s",

#6 Setup Systemd Service For Mattermost

We’ll create a systemd service to start and stop Mattermost:

nano /lib/systemd/system/mattermost.service

Add these lines:




Save, close, and reload the systemd daemon to apply the changes:

sudo systemctl daemon-reload
sudo systemctl start mattermost
sudo systemctl enable mattermost

#7 Configuring Nginx as a Reverse Proxy

Now, using the following command, build a Nginx virtual host configuration file:

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

Include following lines:

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.your-domain;

   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 65;
       send_timeout 200;
       lingering_timeout 5;
       proxy_connect_timeout 80;
       proxy_send_timeout 300;
       proxy_read_timeout 80s;
       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;

Save and close the file, then run the command:

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

#8 Securing Mattermost with Let’s Encrypt SSL

Install Certbot first on your Debian system using the command below:

sudo apt install certbot python3-certbot-nginx

Generate the certificates using the command:

certbot --nginx -d

Then enter an email address for the certificate. After that, you must accept the T&Cs and decide whether or not to give the Electronic Frontier Foundation (EFF) your email address. Optional final step Reload Apache to load all the updated configurations.

#9 Access Mattermost Web Interface

To access the Mattermost online UI, open your web browser and type This screen should appear:

How To Install Mattermost on Debian 11 Bullseye


William Keener

William is a tech writer at Hacktoday. He's been writing how-to guides for about 4 years now and has covered many topics. He loves to cover topics related to Windows, Android, and the latest tricks and tips.

Related Articles

Back to top button