How to Install Mattermost on AlmaLinux

how to install mattermost on almalinux

Mattermost is an open-source messaging system. It offers a secure and flexible chat service with file sharing, search functions, and other integrations. Mattermost is easy to use and comes with a very friendly user interface, making it an excellent free alternative to Slack, Microsoft Teams, and any other similar services. In this tutorial, we will show you how to install Mattermost on AlmaLinux.


  • An AlmaLinux VPS with at least 2GB of RAM – This tutorial should work with both AlmaLinux 8 and 9, but that may change in the future.
  • root SSH access or a regular user with sudo privileges

Step 1: Log in to your server via SSH

First, you will need to log in to your AlmaLinux 8 VPS via SSH as the root user:

ssh root@IP_Address -p Port_number

You will need to replace ‘IP_Address’ and ‘Port_number’ with your server’s respective IP address and SSH port number. Additionally, replace ‘root’ with the username of the system user with sudo privileges.

You can check whether you have the proper AlmaLinux version installed on your server with the following command:

# cat /etc/almalinux-release

You will get an output like this:

AlmaLinux release 8.8 (Sapphire Caracal)

In this article, we are using ‘root’ to execute the shell commands. If you want to use your regular user with sudo privileges to run the commands, make sure to append ‘sudo’ in front of the commands.

Step 2: Update the System

Before starting, you have to make sure that all AlmaLinux OS packages installed on the server are up to date. You can do this by running the following commands:

# dnf update
# dnf upgrade

If there is a kernel update, you will need to reboot in order to load the new kernel version. Now that we’re up-to-date, we can begin with the installation.

Step 3. Create User

In this step, we are going to create a new system user to run the Mattermost service under. Let’s execute the command below; you can substitute ‘mattermost’ with any username you like.

# useradd -mrd /opt/mattermost mattermost -s "$(which bash)"

The command above will automatically create the directory /opt/mattermost as the home directory for user ‘mattermost’. We will use this directory as the installation directory for Mattermost.

Step 4. Install MariaDB and Create a Database

Mattermost supports PostgreSQL 11.0+, MySQL 5.7.12, 8.0.12+, or equivalent MariaDB server. Let’s install MariaDB through the AlmaLinux repository. To do this, simply run the following command:

# dnf install mariadb-server -y

MariaDB has now been installed, but it is not running at the moment. Let’s configure it to run now and run upon server reboot.

# systemctl enable --now mariadb

After the installation is completed, you can improve the security of your MySQL server, by running the mysql_secure_installation script:

# mysql_secure_installation

You will be asked to create a new password for your MySQL root account. It is recommended to answer all questions with Y (YES). As seen in the picture below, we created a strong MySQL password, removed the test database and removed anonymous users as well.

MariaDB is running and is secured now. Next, let’s create a new database for our mattermost application. First, we need to connect to MariaDB/MySQL server by running the command:

# mysql -u root -p

You will be prompted for your MariaDB root password which has been set when running the mysql_secure_installation command earlier in this step.

This will grant you access to the MariaDB shell:

Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 17
Server version: 10.3.35-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> 

Let’s create a new database and database user now.

MariaDB [(none)]> CREATE DATABASE mattermostdb;
Query OK, 1 row affected (0.001 sec)

MariaDB [(none)]> CREATE USER 'mattermost'@'localhost' IDENTIFIED BY 'm0d1fyth15';
Query OK, 0 rows affected (0.000 sec)

MariaDB [(none)]> GRANT ALL PRIVILEGES ON mattermostdb.* TO 'mattermost'@'localhost' WITH GRANT OPTION;
Query OK, 0 rows affected (0.000 sec)

Query OK, 0 rows affected (0.001 sec)

MariaDB [(none)]> \q

Make sure to change the username and password for the user that will control the Mattermost database in order to improve security. Now we can proceed to the next step.

Step 5. Download and Install Mattermost

In the earlier step, we created a system user called ‘mattermost’; let’s switch to this user and download Mattermost. If you want to download the most recent tarball package, you can go to their download page and replace the link in the command below with the newest version.

# su - mattermost
$ wget -O mattermost.tar.gz
$ tar -xzvf mattermost.tar.gz --strip-component 1

Before running Mattermost, we need to configure it to connect to our database.

$ cp /opt/mattermost/config/config.json /opt/mattermost/config/config.defaults.json

Configure the following properties in this file:

Set the DriverName field to "mysql".
Set the DataSource field to "dbuser:@:3306/dbname?charset=utf8mb4,utf8\u0026readTimeout=30s\u0026writeTimeout=30s",

Replace dbuser, dbpassword with your dbuser and dbpassword you created in the previous step; in this case, it would be:

"DataSource": "mattermost:m0d1fyth15@tcp(localhost:3306)/mattermostdb?charset=utf8mb4,utf8\u0026readTimeout=30s\u0026writeTimeout=30s",
Set your "SiteURL" to the domain name you want for your Mattermost application (e.g.

Save the file, then exit from nano editor

Then, exit from user ‘mattermost’:

$ exit

Step 6. Create Systemd Service File

We need to create a systemd service file to easily manage our Mattermost service. Let’s create a systemd service file for Mattermost.

# nano /etc/systemd/system/mattermost.service

Paste the following into the systemd service file, then save it.




Save the file, exit from the nano editor, then reload systemd for the changes to take effect.

# systemctl daemon-reload

Now, let’s enable Mattermost to run on boot and run the service now.

# systemctl enable --now mattermost

The command above will return an output like this:

Created symlink /etc/systemd/system/ → /etc/systemd/system/mattermost.service.

At this point, Mattermost should be up and running, and it will automatically run on boot. To verify, run this command:

# systemctl status mattermost

You will see an output similar to this

● mattermost.service - Mattermost
Loaded: loaded (/etc/systemd/system/mattermost.service; enabled; vendor preset: disabled)
Active: active (running) since Thu 2023-09-14 21:18:02 EDT; 2min 8s ago
Main PID: 55973 (mattermost)
Tasks: 26 (limit: 4737)
Memory: 236.5M
CGroup: /system.slice/mattermost.service
├─55973 /opt/mattermost/bin/mattermost
├─56133 plugins/com.mattermost.nps/server/dist/plugin-linux-amd64
├─56139 plugins/playbooks/server/dist/plugin-linux-amd64
└─56146 plugins/com.mattermost.calls/server/dist/plugin-linux-amd64

Sep 14 21:18:01 localhost.localdomain mattermost[55973]: {"timestamp":"2023-09-14 21:18:01.957 -04:00","level":"info","msg":"got public IP address for>
Sep 14 21:18:01 localhost.localdomain mattermost[55973]: {"timestamp":"2023-09-14 21:18:01.957 -04:00","level":"info","msg":"rtc: server is listening >
Sep 14 21:18:01 localhost.localdomain mattermost[55973]: {"timestamp":"2023-09-14 21:18:01.959 -04:00","level":"info","msg":"rtc: server is listening >
Sep 14 21:18:01 localhost.localdomain mattermost[55973]: {"timestamp":"2023-09-14 21:18:01.961 -04:00","level":"info","msg":"Listening TCP on>
Sep 14 21:18:02 localhost.localdomain mattermost[55973]: {"timestamp":"2023-09-14 21:18:02.660 -04:00","level":"info","msg":"Starting Server...","call>
Sep 14 21:18:02 localhost.localdomain mattermost[55973]: {"timestamp":"2023-09-14 21:18:02.664 -04:00","level":"info","msg":"Server is listening on [:>
Sep 14 21:18:02 localhost.localdomain mattermost[55973]: {"timestamp":"2023-09-14 21:18:02.664 -04:00","level":"info","msg":"Sending systemd READY not>
Sep 14 21:18:02 localhost.localdomain systemd[1]: Started Mattermost.

At this point, you should be able to access mattermost at http://YOUR_SERVER_IP_ADDRESS:8065

Step 7. Install and Configure Nginx

To access Mattermost without needing to specify the port at the end of the URL, we need to install and configure a reverse proxy. In this step, we are going to install Nginx.

Need a fast and easy fix?
✔ Unlimited Managed Support
✔ Supports Your Software
✔ 2 CPU Cores
✔ 2 GB RAM
✔ 50 GB PCIe4 NVMe Disk
✔ 1854 GeekBench Score
✔ Unmetered Data Transfer

Now just $43 .99

# dnf install nginx

Once installed, we can create an Nginx server block for our mattermost website.

# nano /etc/nginx/conf.d/mattermost.conf

Then, insert the following into the file.

server {
  listen 80;

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_http_version 1.1;
       proxy_pass http://backend;

   location / {
       client_max_body_size 50M;
       proxy_set_header X-Frame-Options SAMEORIGIN;
       proxy_buffers 256 16k;
       proxy_buffer_size 16k;
       proxy_read_timeout 600s;
       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://backend;

Make sure to replace with the domain you chose earlier. Save the file, then exit from the editor. Then, let’s start and enable Nginx.

# systemctl enable --now nginx

That’s it; you should be able to access Mattermost at now.

Congratulations! You followed this article and now you have successfully installed Mattermost on your AlmaLinux machine.

Of course, you don’t have to spend your time following this article to install Mattermost on AlmaLinux if you have an active AlmaLinux VPS Hosting service with us, in which case you can simply ask our expert Linux admins to install Mattermost for you. Our admins are available 24×7 and will respond to your request immediately. They will also help you install an SSL certificate on your Mattermost server, optimize your Mattermost for the best performance and capacity, and more.

PS. If you liked this post on how to install Mattermost on AlmaLinux, please share it with your friends on social networks or simply leave a reply below. Thanks.

Leave a Comment