Install Mattermost on Rocky Linux 8

Today’s guide will help Rocky Linux users to install Mattermost on Rocky Linux 8. Mattermost is a free and open-source platform for collaboration and messaging like Microsoft Teams and Slack. Apart from the given functionalities, you can use Mattermost to share files, search and integrate modules such as GitHub, GitLab, Jira and Zoom to extend functionalities.

Prerequisites

To install Mattermost on Rocky Linux 8, you need:

  • Root privileges
  • A web server
  • A database server
  • Stable internet connection

Install and configure MySQL Database Server

  • Install MySQL server using the command:
sudo dnf install mysql-server -y
  • Enable MySQL server
sudo systemctl enable mysqld.service
  • Start MySQL server
sudo systemctl start mysqld.service
  • Secure your Database server installation.
sudo mysql_secure_installation
  • Log in to the MySQL console with
mysql -u root -p
  • Create the database mattermost:
CREATE mattermost;
  • Create a new user with a username: itnixpro and password: Itnixpro!2022. Replace the fields accordingly.
CREATE USER 'itnixpro'@'localhost' IDENTIFIED BY 'Itnixpro!2022';
  • Grant the necessary permissions to the new user to the database:
GRANT ALL PRIVILEGES ON mattermost.* to itnixpro@localhost;
  • Reload grant tables:
FLUSH PRIVILEGES;
  • Exit out of MySQL
exit

Install Mattermost on Rocky Linux 8

  • Install Mattermost on Rocky Linux 8 using a tar file downloaded from the official Mattermost download using wget command. Save the file under downloads directory:
wget -P ~/Downloads https://releases.mattermost.com/6.6.1/mattermost-6.6.1-linux-amd64.tar.gz
  • Move to Downloads directory
cd ~/Downloads
  • Extract the Mattermost files.
tar -xvzf mattermost*.gz
  • Move the extracted file to the /opt directory.
sudo mv mattermost /opt
  • Create the storage directory for files.
sudo mkdir /opt/mattermost/data

Create a new user and group with proper permissions

  • Create a system user and group called mattermost that will run service.
sudo useradd --system --user-group mattermost
  • Give the mattermost user and group ownership to the Mattermost files.
sudo chown -R mattermost:mattermost /opt/mattermost
  • Grant the /opt/mattermost directory write permission.
sudo chmod -R g+w /opt/mattermost

Configure Mattermost Server with MySQL

  • Configure the driver connection setting:
sudo nano /opt/mattermost/config/config.json

Press CTRL+W to find the lines that start with:

  • "DriverName":
  • "DataSource":

Change DriverName value to mysql

"DriverName": "mysql",

Replace the line starting with DataSource and edit itnixpro, Itnixpro!2022 and mattermost to the database user, password and database you created earlier to look as below

“DataSource”: “itnixpro:Itnixpro!2022@tcp(127.0.0.1:3306)/mattermost?charset=utf8mb4,utf8\u0026readTimeout=30s\u0026writeTimeout=30s”,

Configure Systemd Service

Configure Mattermost to use systemd for starting and stopping Mattermost service.

  • Create a systemd unit file.
sudo nano /etc/systemd/system/mattermost.service
  • Copy and paste the configuration below
[Unit]
Description=Mattermost
After=syslog.target network.target mysqld.service

[Service]
Type=notify
WorkingDirectory=/opt/mattermost
User=mattermost
ExecStart=/opt/mattermost/bin/mattermost
PIDFile=/var/spool/mattermost/pid/master.pid
TimeoutStartSec=3600
LimitNOFILE=49152

[Install]
WantedBy=multi-user.target
  • Switch off SELinux and set permissive mode
sudo setenforce 0
sudo sed -i 's/^SELINUX=.*/SELINUX=permissive/g' /etc/selinux/config
  • Reload the daemon
sudo systemctl daemon-reload
  • Set up Mattermost run on startup
sudo systemctl enable mattermost.service
  • Now start the Mattermost
sudo systemctl start mattermost.service
  • Check Mattermost status
systemctl status mattermost
  • Your output should be similar to:
[itnixpro@localhost mattermost]$ sudo systemctl status mattermost
● mattermost.service - Mattermost
   Loaded: loaded (/etc/systemd/system/mattermost.service; enabled; vendor preset: disabled)
   Active: active (running) since Sun 2022-05-08 16:41:34 EAT; 6min ago
 Main PID: 14811 (mattermost)
    Tasks: 51 (limit: 17722)
   Memory: 337.8M
   CGroup: /system.slice/mattermost.service
           ├─14811 /opt/mattermost/bin/mattermost
           ├─15218 plugins/com.mattermost.plugin-channel-export/server/dist/plugin-linux-amd64
           ├─15252 plugins/playbooks/server/dist/plugin-linux-amd64
           ├─15259 plugins/focalboard/server/dist/plugin-linux-amd64
           └─15269 plugins/com.mattermost.nps/server/dist/plugin-linux-amd64

May 08 16:41:11 localhost.localdomain mattermost[14811]: {"timestamp":"2022-05-08 16:41:11.376 +03:00","level":"info","msg":"Initialized notificatio>
May 08 16:41:20 localhost.localdomain mattermost[14811]: {"timestamp":"2022-05-08 16:41:20.507 +03:00","level":"error","msg":"Metrics server could n>
May 08 16:41:33 localhost.localdomain mattermost[14811]: {"timestamp":"2022-05-08 16:41:33.589 +03:00","level":"info","msg":"Server.Start","caller":>
May 08 16:41:33 localhost.localdomain mattermost[14811]: {"timestamp":"2022-05-08 16:41:33.978 +03:00","level":"info","msg":"Failed to fetch license>
May 08 16:41:33 localhost.localdomain mattermost[14811]: {"timestamp":"2022-05-08 16:41:33.985 +03:00","level":"error","msg":"Unable to activate plu>
May 08 16:41:34 localhost.localdomain mattermost[14811]: {"timestamp":"2022-05-08 16:41:34.393 +03:00","level":"error","msg":"Mail server connection>
May 08 16:41:34 localhost.localdomain mattermost[14811]: {"timestamp":"2022-05-08 16:41:34.462 +03:00","level":"info","msg":"Starting Server...","ca>
May 08 16:41:34 localhost.localdomain systemd[1]: Started Mattermost.
May 08 16:41:34 localhost.localdomain mattermost[14811]: {"timestamp":"2022-05-08 16:41:34.736 +03:00","level":"info","msg":"Server is listening on >
May 08 16:41:34 localhost.localdomain mattermost[14811]: {"timestamp":"2022-05-08 16:41:34.736 +03:00","level":"info","msg":"Sending systemd READY n>
lines 1-23/23 (END)

Install Nginx web server

Setup Nginx web server as a reverse proxy for improved security.

  • Install Nginx:
sudo dnf install nginx -y
  • Create a configuration file for Nginx:
sudo nano /etc/nginx/conf.d/mattermost.conf
  • Add the configurations below, save and close the file
upstream backend {
   server 127.0.0.1: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    chat.itnixprotest.com;

   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_pass http://backend;
   }

   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://backend;
   }
}

Edit the server_name and server with respective to the previous settings.

  • Delete the default NGINX configuration file.
sudo rm /etc/nginx/sites-enabled/default
  • Restart Nginx:
sudo systemctl restart nginx

Access Mattermost Web Interface

Open your browser and enter your server-IP:8065, for instance http://localhost:8065.

The initial page loads as below. Create an account for logging in and proceed by clicking on Create account

On the next page, type in your organization name:

Next leave the server’s URL unchanged and click continue

Select the purpose you want to use Mattermost for, like Team communication

Next, select additional tools to extend functionalities or click skip for now:

Next input your channel name or skip:

Finally, share the link of the channel with your team and/pr click Finish setup

You will be redirected to the dashboard:

Nice! You have managed to install Mattermost on Rocky Linux 8. Thank you for visiting Itnixpro and I hope you enjoy using Mattermost for communication.

Find more information in Mattermost documentation.

More interesting articles

Install Mattermost on Ubuntu 22.04
Install Nginx Web Server on Rocky Linux

Install and Configure DHCP client on Rocky Linux

Android Developer | Linux | Technical Writer | Backend Developer

Leave a Comment