Install Mattermost on Rocky Linux 8 and RHEL 8

In this guide, we want to show you to Install and Configure Mattermost on Rocky Linux 8 and RHEL 8 and Access its dashboard through the web interface.

Mattermost is a free, open-source, secure, and popular communication tool that is an alternative to Slack. It brings many amazing features that you can use to communicate with your team.

How To Install Mattermost on Rocky Linux 8 and RHEL 8?

To complete this guide, you must have access to your server as a non-root user with sudo privileges and set up a basic firewall. For this purpose, you can visit this guide on Initial Server Setup with Rocky Linux 8.

Also, you need a domain name that is pointed to your server’s IP address.

Now follow the steps below to start your Mattermost installation.

Step 1 – Install and Configure MariaDB for Mattermost

In this guide, we will use MariaDB as our database management system. So you need to run the system update and install the MariaDB server with the following commands:

# sudo dnf update -y
# sudo dnf install mariadb-server -y

Start and enable your MariaDB service with the following command:

sudo systemctl enable --now mariadb

Then, secure your MariaDB installation and set a root password for your MariaDB by using the following script:

sudo mysql_secure_installation

Now proceed to the following step to configure MariaDB for Mattermost.

At this point, you need to log in to your MariaDB shell with the following command:

sudo mysql -u root -p

Then, you must create a Mattermost database and database user with a password on Rocky Linux 8. To do this, run the following commands:

MariaDB [(none)]> CREATE DATABASE mattermostdb;
MariaDB [(none)]> CREATE USER 'orca'@'%';
MariaDB [(none)]> SET PASSWORD FOR 'orca'@'%' = PASSWORD('strongpassword');

Next, you need to give all the privileges to the Mattermost database and database user with the command below:

MariaDB [(none)]> GRANT ALL ON mattermostdb.* TO 'orca'@'%' IDENTIFIED BY 'strongpassword' WITH GRANT OPTION;

Next, flush the privileges and exit from the MariaDB console:

MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> EXIT;

Step 2 – Download Mattermost on Rocky Linux 8 / RHEL8

At this point, you need to create a dedicated user and group for Mattermost. To do this, you can use the following command:

sudo useradd --system --user-group mattermost

Then, you need to visit the Mattermost release page and get the latest version by using the following wget command on your Rocky Linux 8:

sudo wget https://releases.mattermost.com/8.0.1/mattermost-8.0.1-linux-amd64.tar.gz

When your download is completed, extract your file in the /opt directory:

sudo tar xvzf mattermost-8.0.1-linux-amd64.tar.gz -C /opt/

Next, use the following command to install a data directory to store your Mattermost files:

sudo mkdir /opt/mattermost/data

Now set the correct permission and ownership by using the following commands:

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

Step 3 – Configure Mattermost on Rocky Linux 8 / RHEL8

At this point, you need to edit the Mattermost configuration file and define your site URL and database settings to the file. To do this, open the Mattermost config file with your desired text editor, here we use the vi editor:

sudo vi /opt/mattermost/config/config.json

At the file, define your site URL and database settings as shown below:

"SiteURL": "http://mattermost.example.com", 
"DriverName": "mysql", 
"DataSource": "orca:strongpassword@tcp(localhost:3306)/mattermostdb?charset=utf8mb4,utf8&writeTimeout=30s",

When you are done, save and close the file.

Step 4 – How To Start Mattermost Server?

Then, change to the Mattermost directory and Start the Mattermost server as the user Mattermost with the following command:

# cd /opt/mattermost
# sudo -u mattermost ./bin/mattermost

When the server starts, you will see some log information and the text Server is listening on :8065. Then, you can stop the server by pressing Ctrl C.

Step 5 – Manage Mattermost Service on Rocky Linux 8 / RHEL8

At this point, you need to create a systemd unit file to manage your Mattermost service. To do this, run the command below:

sudo vi /etc/systemd/system/mattermost.service

Add the following content to the file:

[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
KillMode=mixed
LimitNOFILE=49152

[Install]
WantedBy=multi-user.target

When you are done, save and close the file.

Now reload the systemd service to apply the changes:

sudo systemctl daemon-reload

Next, use the following commands to start and enable your service to start at boot:

# sudo systemctl start mattermost
# sudo systemctl enable mattermost

Verify that your Mattermost service is active and running on Rocky Linux 8:

sudo systemctl status mattermost

In your output you will see:

Output
● mattermost.service - Mattermost
   Loaded: loaded (/etc/systemd/system/mattermost.service; enabled; vendor pres>
   Active: active (running) since Mon 2023-08-07 09:52:32 EDT; 2min 51s ago
 Main PID: 93450 (mattermost)
    Tasks: 30 (limit: 23699)
   Memory: 282.6M
   CGroup: /system.slice/mattermost.service
           ├─93450 /opt/mattermost/bin/mattermost
           ├─93458 plugins/com.mattermost.nps/server/dist/plugin-linux-amd64
           ├─93465 plugins/playbooks/server/dist/plugin-linux-amd64
           └─93471 plugins/com.mattermost.calls/server/dist/plugin-linux-amd64
...

Step 6 – Configure Nginx as Reverse Proxy for Mattermost

At this point, that you have installed Mattermost on Rocky Linux 8, you need to configure Nginx as a reverse proxy for Mattermost.

First, install Nginx on Rocky Linux 8 with the following command:

sudo dnf install nginx -y

Next, you need to create an Nginx virtual host configuration file. Create and open the file with your favorite text editor, here we use vi:

sudo vi /etc/nginx/conf.d/mattermost.conf

Add the following contents to the file:

 server {
        listen       80;
        server_name  mattermost.example.com;

        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;

        location / {
	proxy_pass http://localhost:8065/;
            index  index.html index.htm;
        }

        error_page 404 /404.html;
            location = /40x.html {
        }

        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }
    }

Remember to replace the domain names with your own in the file.

When you are done, save and close the file.

Verify the Nginx for any configuration error by using the following command:

nginx -t
Output
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

Then, start and enable your Nginx service with the following commands:

# sudo systemctl start nginx
# sudo systemctl enable nginx

Step 7 – Configure Firewall Rules for Matetrmost

If you have a running firewall, you must allow port HTTP, HTTPS, and port Mattermost which is 8065. To do this, you can run the commands below:

# sudo firewall-cmd --add-service=http --permanent
# sudo firewall-cmd --add-service=https --permanent
# sudo firewall-cmd --permanent --add-port=8065/tcp

To apply the new rules, reload the firewall:

sudo firewall-cmd --reload

Step 8 – How To Access Mattermost Dashboard on RHEL 8?

At this point, you can access the Mattermost web interface by typing your server’s IP address or your domain name in your web browser followed by 8065:

http://your-domain-name-or-IP:8065

You will see the Mattermost create account screen, set your account and click Create Account as shown below:

Create mattermost account

In the next window, enter your organization name and click continue.

Name of organization on Mattermost

Then, you can choose the tools that you use or skip them.

Tools you work in Mattermost

Next, your invitation link is provided for you. You can use this to invite your team members. Click Finish Setup.

Mattermost invitation link

Finally, you can see your Mattermost dashboard.

Mattermost dashboard RHEL 8

That’s it, you’ve just configured Mattermost to Rocky Linux 8 Server. From there you can collaborate with your teams.

Conclusion

At this point, you have learned to configure MariaDB as a database engine for Mattermost and download the latest release from the source and configure Mattermost to access it from the web browser.

Hope you enjoy using it. For more guides and articles, you can visit the Orcacore website.

Newsletter Updates

Enter your email address below and subscribe to our newsletter

Stay informed and not overwhelmed, subscribe now!