Install Mattermost Chat Server on CentOS 8 - CentLinux


Sunday, 25 October 2020

Install Mattermost Chat Server on CentOS 8


Mattermost is an open source, self-hosted team chat and collaboration software. In this article, you will learn how to install Mattermost chat server on CentOS 8.


Table of Contents:


    What is Mattermost? :

    Mattermost is a free Slack alternative. It is an open source, self-hosted server that has team chat, file sharing, search, integration and collaboration features.

    Mattermost is designed as an internal chat for organisations and companies, and mostly markets itself as an open-source alternative to Slack.

    Mattermost is available in open source and enterprise editions. Open Source edition is free, whereas Enterprise editions have per user license cost. You can find Mattermost Pricing plans at their official website.


    Environment Specification:

    We are using a minimal CentOS 8 virtual machine with following specifications.

    • CPU - 3.4 Ghz (2 cores)
    • Memory - 2 GB
    • Storage - 20 GB
    • Operating System - CentOS 8.0
    • Hostname –
    • IP Address - /24


    Updating Installed Packages on Linux Server:

    By using a SSH client, connect with as root user.

    Follow the best practice and upgrade all installed software packages on your Linux server by using dnf command.

    [root@mattermost-02 ~]# dnf update -y Last metadata expiration check: 0:00:35 ago on Sun 25 Oct 2020 09:25:49 AM PKT. Dependencies resolved. Nothing to do. Complete!

    Well, our Linux server is already up-to-date.


    Installing MySQL Database Server on CentOS 8:

    Mattermost requires a backend database server to store its data. It supports MySQL and PostgreSQL databases.

    Here, We are installing MariaDB database server, a famous fork of MySQL. If you already have a working MySQL database server, then you can skip this step and create the Mattermost database on that MySQL server.

    MariaDB server is available in standard yum repositories, therefore you can install it with the help of a dnf command.

    [root@mattermost-02 ~]# dnf install -y mariadb-server ... Installed: mariadb-3:10.3.17-1.module_el8.1.0+257+48736ea6.x86_64 mariadb-backup-3:10.3.17-1.module_el8.1.0+257+48736ea6.x86_64 mariadb-common-3:10.3.17-1.module_el8.1.0+257+48736ea6.x86_64 mariadb-connector-c-3.0.7-1.el8.x86_64 mariadb-connector-c-config-3.0.7-1.el8.noarch mariadb-errmsg-3:10.3.17-1.module_el8.1.0+257+48736ea6.x86_64 mariadb-gssapi-server-3:10.3.17-1.module_el8.1.0+257+48736ea6.x86_64 mariadb-server-3:10.3.17-1.module_el8.1.0+257+48736ea6.x86_64 mariadb-server-utils-3:10.3.17-1.module_el8.1.0+257+48736ea6.x86_64 perl-Carp-1.42-396.el8.noarch perl-DBD-MySQL-4.046-3.module_el8.1.0+203+e45423dc.x86_64 perl-DBI-1.641-3.module_el8.1.0+199+8f0a6bbd.x86_64 perl-Data-Dumper-2.167-399.el8.x86_64 perl-Digest-1.17-395.el8.noarch perl-Digest-MD5-2.55-396.el8.x86_64 perl-Encode-4:2.97-3.el8.x86_64 perl-Errno-1.28-416.el8.x86_64 perl-Exporter-5.72-396.el8.noarch perl-File-Path-2.15-2.el8.noarch perl-File-Temp-0.230.600-1.el8.noarch perl-Getopt-Long-1:2.50-4.el8.noarch perl-HTTP-Tiny-0.074-1.el8.noarch perl-IO-1.38-416.el8.x86_64 perl-IO-Socket-IP-0.39-5.el8.noarch perl-IO-Socket-SSL-2.066-4.el8.noarch perl-MIME-Base64-3.15-396.el8.x86_64 perl-Math-BigInt-1:1.9998.11-7.el8.noarch perl-Math-Complex-1.59-416.el8.noarch perl-Mozilla-CA-20160104-7.el8.noarch perl-Net-SSLeay-1.88-1.el8.x86_64 perl-PathTools-3.74-1.el8.x86_64 perl-Pod-Escapes-1:1.07-395.el8.noarch perl-Pod-Perldoc-3.28-396.el8.noarch perl-Pod-Simple-1:3.35-395.el8.noarch perl-Pod-Usage-4:1.69-395.el8.noarch perl-Scalar-List-Utils-3:1.49-2.el8.x86_64 perl-Socket-4:2.027-3.el8.x86_64 perl-Storable-1:3.11-3.el8.x86_64 perl-Term-ANSIColor-4.06-396.el8.noarch perl-Term-Cap-1.17-395.el8.noarch perl-Text-ParseWords-3.30-395.el8.noarch perl-Text-Tabs+Wrap-2013.0523-395.el8.noarch perl-Time-Local-1:1.280-1.el8.noarch perl-URI-1.73-3.el8.noarch perl-Unicode-Normalize-1.25-396.el8.x86_64 perl-constant-1.33-396.el8.noarch perl-interpreter-4:5.26.3-416.el8.x86_64 perl-libnet-3.11-3.el8.noarch perl-libs-4:5.26.3-416.el8.x86_64 perl-macros-4:5.26.3-416.el8.x86_64 perl-parent-1:0.237-1.el8.noarch perl-podlators-4.11-1.el8.noarch perl-threads-1:2.21-2.el8.x86_64 perl-threads-shared-1.58-2.el8.x86_64 psmisc-23.1-4.el8.x86_64 Complete!

    Enable and start MariaDB database service.

    [root@mattermost-02 ~]# systemctl enable --now mariadb.service Created symlink /etc/systemd/system/mysql.service â /usr/lib/systemd/system/mariadb.service. Created symlink /etc/systemd/system/mysqld.service â /usr/lib/systemd/system/mariadb.service. Created symlink /etc/systemd/system/ â /usr/lib/systemd/system/mariadb.service.

    Since, you have installed a fresh MySQL server, therefore, you are required to perform initial configuration of the MySQL instance.

    Use the following Linux command to configure MySQL instance.

    [root@mattermost-02 ~]# mysql_secure_installation NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY! In order to log into MariaDB to secure it, we'll need the current password for the root user. If you've just installed MariaDB, and you haven't set the root password yet, the password will be blank, so you should just press enter here. Enter current password for root (enter for none): OK, successfully used password, moving on... Setting the root password ensures that nobody can log into the MariaDB root user without the proper authorisation. Set root password? [Y/n] Y New password: Re-enter new password: Password updated successfully! Reloading privilege tables.. ... Success! By default, a MariaDB installation has an anonymous user, allowing anyone to log into MariaDB without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment. Remove anonymous users? [Y/n] Y ... Success! Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network. Disallow root login remotely? [Y/n] Y ... Success! By default, MariaDB comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment. Remove test database and access to it? [Y/n] Y - Dropping test database... ... Success! - Removing privileges on test database... ... Success! Reloading the privilege tables will ensure that all changes made so far will take effect immediately. Reload privilege tables now? [Y/n] Y ... Success! Cleaning up... All done! If you've completed all of the above steps, your MariaDB installation should now be secure. Thanks for using MariaDB!

    Connect with MySQL server as root database user.

    [root@mattermost-02 ~]# mysql -u root -p Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 16 Server version: 10.3.17-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)]>

    Create a new database user, that will own the Mattermost software database.

    MariaDB [(none)]> create user 'mmuser'@'localhost' identified by 'mmpwd'; Query OK, 0 rows affected (0.001 sec)

    Now create the mattermost database.

    MariaDB [(none)]> create database mattermost; Query OK, 1 row affected (0.001 sec)

    Grant full rights on mattermost database to mmuser.

    MariaDB [(none)]> grant all privileges on mattermost.* to 'mmuser'@'localhost'; Query OK, 0 rows affected (0.001 sec)

    Exit from mysql shell.

    MariaDB [(none)]> exit Bye


    Installing Mattermost Chat Server on CentOS 8:

    To download Mattermost, go to their official website and obtain the URL of latest version.


    By using wget command, download the latest version of Mattermost software as follows.

    [root@mattermost-02 ~]# cd /tmp [root@mattermost-02 tmp]# wget --2020-10-25 10:14:42-- Resolving (,,, ... Connecting to (||:443... connected. HTTP request sent, awaiting response... 200 OK Length: 183523028 (175M) [application/x-gzip] Saving to: âmattermost-5.28.1-linux-amd64.tar.gzâ mattermost-5.28.1-l 100%[===================>] 175.02M 515KB/s in 5m 27s 2020-10-25 10:20:11 (549 KB/s) - âmattermost-5.28.1-linux-amd64.tar.gzâ saved [183523028/183523028]

    Extract the downloaded tarball with the help of tar command.

    [root@mattermost-02 tmp]# tar xvf mattermost-5.28.1-linux-amd64.tar.gz ... mattermost/prepackaged_plugins/mattermost-plugin-zoom-v1.3.1-linux-amd64.tar.gz.sig mattermost/prepackaged_plugins/mattermost-plugin-autolink-v1.1.2-linux-amd64.tar.gz.sig mattermost/prepackaged_plugins/mattermost-plugin-aws-SNS-v1.0.2-linux-amd64.tar.gz.sig mattermost/prepackaged_plugins/mattermost-plugin-antivirus-v0.1.2-linux-amd64.tar.gz.sig mattermost/prepackaged_plugins/mattermost-plugin-welcomebot-v1.1.1-linux-amd64.tar.gz.sig mattermost/prepackaged_plugins/mattermost-plugin-welcomebot-v1.1.1-linux-amd64.tar.gz

    After extraction, move the mattermost directory (that was extracted from tarball) to /opt directory.

    [root@mattermost-02 tmp]# mv mattermost /opt/

    Create a data directory for Mattermost application.

    [root@mattermost-02 tmp]# mkdir /opt/mattermost/data

    Create a Linux user to own Mattermost software and in-memory processes.

    [root@mattermost-02 tmp]# cd [root@mattermost-02 ~]# useradd -r -U mattermost

    Adjust the file permissions and SELinux file contexts of the /opt/mattermost directory.

    [root@mattermost-02 ~]# chown -R mattermost:mattermost /opt/mattermost [root@mattermost-02 ~]# chmod -R g+w /opt/mattermost [root@mattermost-02 ~]# restorecon -R /opt/mattermost/

    Mattermost Configurations are located in /opt/mattermost/config/config.json.

    You need to edit this configuration file to update settings according to your environment.

    [root@mattermost-02 ~]# vi /opt/mattermost/config/config.json

    Find and set following directives related to Mattermost backend database. You may find them under "SqlSettings" configuration block.

    "DriverName": "mysql", "DataSource": "mmuser:mmpwd@tcp(localhost:3306)/mattermost?charset=utf8mb4,utf8\u0026readTimeout=30s\u0026writeTimeout=30s",

    Find and set following directive. You may find it under "ServiceSettings" configuration block.

    "SiteURL": "",

    Please ensure that the hostname of your Linux server is resolvable. You can either configure an Authoritative DNS Server or simply use the local DNS resolver.

    Here, we are using the Local DNS resolver.

    [root@mattermost-02 ~]# vi /etc/hosts

    Add following entry therein. mattermost-02

    Mattermost software has been installed and configured. You can test it by using following command.

    [root@mattermost-02 ~]# cd /opt/mattermost/ [root@mattermost-02 mattermost]# sudo -u mattermost ./bin/mattermost {"level":"info","ts":1603605355.5773954,"caller":"app/server.go:214","msg":"Server is initializing..."} {"level":"info","ts":1603605355.5775044,"caller":"app/web_hub.go:83","msg":"Starting websocket hubs","number_of_hubs":2} {"level":"warn","ts":1603605355.5775716,"caller":"app/server.go:223","msg":"Sentry reporting is enabled, but SENTRY_DSN is not set. Disabling reporting."} {"level":"info","ts":1603605355.5795093,"caller":"utils/i18n.go:90","msg":"Loaded system translations","for locale":"en","from locale":"/opt/mattermost/i18n/en.json"} {"level":"info","ts":1603605355.5830262,"caller":"sqlstore/supplier.go:232","msg":"Pinging SQL","database":"master"} {"level":"info","ts":1603605355.7059023,"caller":"app/license.go:54","msg":"License key from required to unlock enterprise features."} {"level":"error","ts":1603605355.7094393,"caller":"app/server.go:414","msg":"Mail server connection test is failed: SendEmailNotifications is not true"} {"level":"info","ts":1603605355.7098377,"caller":"app/server.go:450","msg":"Current version is 5.28.0 (5.28.1/Mon Oct 19 15:20:59 UTC 2020/d991504714aded3b97f95fea8f78a01e6ea125bb/a58154b23e3e254c0accc7d9c02310e33417d1c3)","current_version":"5.28.0","build_number":"5.28.1","build_date":"Mon Oct 19 15:20:59 UTC 2020","build_hash":"d991504714aded3b97f95fea8f78a01e6ea125bb","build_hash_enterprise":"a58154b23e3e254c0accc7d9c02310e33417d1c3"} {"level":"info","ts":1603605355.7098854,"caller":"app/server.go:459","msg":"Enterprise Build","enterprise_build":true} {"level":"info","ts":1603605355.709918,"caller":"app/server.go:465","msg":"Printing current working","directory":"/opt/mattermost"} {"level":"info","ts":1603605355.7099378,"caller":"app/server.go:466","msg":"Loaded config","source":"file:///opt/mattermost/config/config.json"} {"level":"info","ts":1603605355.7284067,"caller":"sqlstore/post_store.go:1626","msg":"Post.Message has size restrictions","max_characters":16383,"max_bytes":65535} {"level":"info","ts":1603605355.7982695,"caller":"bleveengine/bleve.go:267","msg":"UpdateConf Bleve"} {"level":"info","ts":1603605355.826711,"caller":"app/server.go:878","msg":"Starting Server..."} {"level":"info","ts":1603605355.8585243,"caller":"app/server.go:955","msg":"Server is listening on [::]:8065","address":"[::]:8065"}

    The Mattermost service has been started and listening on default port i.e. 8065.


    Configure Autostart of Mattermost Application:

    To enable Mattermost application to autostart at the time of Linux operating system startup. You need to create a Systemd service unit.

    Use the vim editor and create a Systemd service unit for Mattermost.

    [root@mattermost-02 mattermost]# vi /etc/systemd/system/mattermost.service

    Add following directives in this file.

    [Unit] Description=Mattermost postgresql.service [Service] Type=notify WorkingDirectory=/opt/mattermost User=mattermost ExecStart=/opt/mattermost/bin/mattermost PIDFile=/var/spool/mattermost/pid/ TimeoutStartSec=3600 LimitNOFILE=49152 [Install]

    Enable and start Mattermost service.

    [root@mattermost-02 mattermost]# systemctl enable --now mattermost.service Created symlink /etc/systemd/system/ â /etc/systemd/system/mattermost.service.


    Configure Linux Firewall for Mattermost Application:

    Although, Mattermost service is started, but it is still not accessible from the network clients. You have to allow the Mattermost service port in Linux firewall, so it can accept incoming traffic from the network clients.

    You can use firewall-cmd command for this purpose.

    [root@mattermost-02 mattermost]# firewall-cmd --permanent --add-port=8065/tcp success [root@mattermost-02 mattermost]# firewall-cmd --reload success


    Accessing Mattermost Web UI:

    Open URL in a client's browser.


    Because you are accessing Mattermost web UI for the first time, therefore, it is asking to register your email address and create a user account on Mattermost cloud.


    We need to create a Mattermost team for collaboration and chatting.


    Provide a team name and click on "Next>".


    You team has been created. Note down the team URL and communicate it to your Team members.


    Now, you reach at the Mattermost dashboard. The control is in your hand now, customize the Mattermost chat server according to your requirement.



    We have successfully installed Slack alternative i.e. Mattermost chat server on CentOS 8. If you found this guide too advanced then you should buy and read How Linux Works, 2nd Edition: What Every Superuser Should Know Second Edition written by Brian Ward.

    No comments:

    Post a comment