How to Install Mattermost Server on CentOS 8

How to Install Mattermost Server on CentOS 8

Install mattermost server on centOS 8; Through this tutorial, we will learn how to install mattermost server on CentOS 8.

It is very simple to install and configure Mattermost server in centOS system. For this, we do not need to do much, in this simple tutorial, we will learn everything step by step, how to install and configure the server that mattersmost.

How to Install Mattermost Server on CentOS 8

Follow the following steps to install mattermost server on centOS 8:

  • Step 1 – Update System Repositories
  • Step 2 – Install Database Server
  • Step 3 – Install MatterMost
  • Step 4 – Configure Mattermost
  • Step 5 – Configure Nginx with Mattermost
  • Step 6 – Configure Firewall
  • Step 7 – Access Mattermost Web Interface

Step 1 – Update System Repositories

First of all, open the terminal and execute the following command on terminal to update system repositories:

sudo dnf clean all
sudo dnf install epel-release
sudo dnf update

Step 2 – Install Database Server

Execute the following command on terminal to install MariaDB in centos system:

sudo dnf install mariadb-server

And execute the following command on terminal to secure MariaDB using the mysql_secure_installation script:

mysql_secure_installation

Then enable and restart mariadb server by executing the following command on terminal:

sudo systemctl restart mariadb
sudo systemctl status mariadb
sudo systemctl enable mariadb

After database installation, login to MariaDB shell and create database and user for Mattermost:

mysql -u root -p
CREATE DATABASE mattermost;
GRANT ALL PRIVILEGES ON mattermost.* TO mattermost@localhost IDENTIFIED BY 'Your-Strong-Passwd';
FLUSH PRIVILEGES;
QUIT;

Step 3 – Install MatterMost

If we need to create a separate user for our Mattermost server, so, execute the following command on terminal:

sudo useradd -d /opt/mattermost -U -M mattermost

Next, download the latest version of the Mattermost :

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

Unpack the Mattermost archive to the document root directory on our server:

tar xf *.gz
mv mattermost /opt/

Create the storage directory for files:

mkdir /opt/mattermost/data

Also, set the ownership and permissions:

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

Next, we’ll have to set up the database driver in the file /opt/mattermost/config/config.json by making some changes to its contents. Search for “DriverName” and “DataSource” lines and change as follows:

nano /opt/mattermost/config/config.json
"SqlSettings": {
        "DriverName": "mysql",
        "DataSource": "mattermost:Str0ngP@ss@tcp(localhost:3306)/mattermost?charset=utf8mb4,utf8\u0026readTimeout=30s\u0026writeTimeout=30s",
        "DataSourceReplicas": [],
        "DataSourceSearchReplicas": [],
        "MaxIdleConns": 20,
        "ConnMaxLifetimeMilliseconds": 3600000,
        "MaxOpenConns": 300,
        "Trace": false,
        "AtRestEncryptKey": "myyti1r597i99qrk7eu91ywqhaawz4md",
        "QueryTimeout": 30
    },

Save and close the file.

And execute the following command on terminal to change the directory to /opt/mattermost and start the Mattermost server:

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

Step 4 – Configure Mattermost

Execute the following command on terminal to create a new systemd unit file:

nano /etc/systemd/system/mattermost.service
[Unit]
Description=Mattermost
After=syslog.target network.target mariadb.service
[Service]
Type=notify
WorkingDirectory=/opt/mattermost
User=mattermost
ExecStart=/opt/mattermost/bin/mattermost
PIDFile=/var/run/mattermost.pid
TimeoutStartSec=3600
LimitNOFILE=49152
[Install]
WantedBy=multi-user.target

Now, start and enable mattermost server by executing the following command on terminal:

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

Step 5 – Configure Nginx with Mattermost

Execute the following command on terminal to install and configure Nginx as a reverse proxy for better performance and security in centOS system:

sudo dnf install nginx

Then start the Nginx service and enable it to start after system reboot by executing the following command on terminal:

sudo systemctl start nginx
sudo systemctl enable nginx

Now, configure the Nginx web server as a proxy for Mattermost by executing the following command on terminal:

sudo nano /etc/nginx/conf.d/mattermost.conf
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    mattermost.example.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;
   }
}

And execute the following command on terminal to restart the Nginx service to make the changes:

nginx -t
sudo systemctl restart nginx

Step 6 – Configure Firewall

Now, execute the following command on terminal to allow firewall access on HTTP and HTTPS ports:

sudo firewall-cmd --add-service={http,https} --permanent
sudo firewall-cmd --reload

Step 7 – Access Mattermost Web Interface

Open favorite browser hit the following url into it:

http://mattermost.example.com

After that, continue to configure Mattermost by entering an email address and creating an account.

Conclusion

Through this tutorial, we have learned how to install mattermost server on CentOS 8.

Recommended CentOS Tutorials

AuthorAdmin

My name is Devendra Dode. I am a full-stack developer, entrepreneur, and owner of Tutsmake.com. I like writing tutorials and tips that can help other developers. I share tutorials of PHP, Python, Javascript, JQuery, Laravel, Livewire, Codeigniter, Node JS, Express JS, Vue JS, Angular JS, React Js, MySQL, MongoDB, REST APIs, Windows, Xampp, Linux, Ubuntu, Amazon AWS, Composer, SEO, WordPress, SSL and Bootstrap from a starting stage. As well as demo example.

Leave a Reply

Your email address will not be published. Required fields are marked *