Home / How To / How to install and configure Mattermost on CentOS 8

How to install and configure Mattermost on CentOS 8



Mattermost is a free, open source and self-hosted messaging system for business teams. It is written in Golang and React and uses MySQL / MariaDB / PostgreSQL as a database backend. It offers desktop clients for Windows, macOS and Linux, and mobile applications for iOS and Android. It offers very useful features including, one-on-one and group messaging, file sharing, video calling, custom emojis, webhooks and commands and many more.

In this tutorial we will show you how to install Mattermost on CentOS 8.

Prerequisites

  • A server running CentOS 8.
  • A root password is configured on your server.

Installing and configuring the MariaDB database

Mattermost uses MariaDB / MySQL as a database backend. So MariaDB must be installed on your server. If it is not installed, you can install it with the following command:

  dnf install mariadb-server -y 

Once installed, launch the MariaDB service and enable it after system startup with the following command:

  systemctl start mariadb 
systemctl enable mariadb

By default, MariaDB is not secured and the root password is not set in CentOS 8. So you can set it with the following command:

  mysql_secure_installation 

Answer all questions shown below:

  Enter the current root password (specify for none):
Set root password? [Y/n] Y
New password:
Re-enter new password:
Delete anonymous users? [Y/n] Y
Remove root login remotely? [Y/n] Y
Delete the test database and access it? [Y/n] Y
Reload privilege tables now? [Y/n] Y

When you are finished, log in to MariaDB with root users:

  mysql -u root -p 

Enter your root password and then create a database and user for Mattermost with the following command:

  MariaDB [(none)]> CREATE DATABASE mattermostdb; 
MariaDB [(none)]> GIVE ALL PRIVILEGES ON mattermostdb. * TO [email protected] IDENTIFIED BY "password";

Then flush the privileges and exit from the MariaDB shell with the following command:

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

When you're done, you can move on to the next step.

Installing Mattermost

First, you must create a separate user to run Mattermost. You can create it with the following command:

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

Next, download the latest version of Mattermost with the following command:

  wget https: // release. mattermost.com/5.21.0/mattermost-5.21.0-linux-amd64.tar.gzebrit19659009??When the download is complete, extract the downloaded file with the following command: 

  tar -xvzf mattermost-5.21.0 -linux- amd64.tar.gz 

Then move the extracted directory to / opt with the following command:

  etc. mattermost / opt / 

Next, create a data directory inside the most important one and give the correct permissions to the most important one with the following command:

  mkdir / opt / mattermost / data 
chown -R mattermost: mattermost / opt / mattermost
chmod-R g + w / opt / mattermost [19659009] When you're done, you can move on to the next step.

Configuring Mattermost

Next, you must define your database in Matterm OST. You can do this by editing the config.json file:

  nano /opt/mattermost/config/config.json Chapter19659009 ?? Change the following lines according to your database settings: 

    "SqlSettings": {
"DriverName": "mysql",
"DataSource": "mattermost: [email protected] (localhost: 3306) / mattermostdb? Charset = utf8mb4, utf8  u0026readTimeout = 30s  u0026writeTimeout = 30s",

Save and close the file when you are done. Then change the directory to / opt / mattermost and start the Mattermost server with the following command:

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

When the server is successfully started, the following output should be obtained: [19659040] Ads

  {"level": "info", "ts": 1585379681.8383002, "caller": "utils / i18n.go: 83", "msg": "Loaded system translations", "for locale": "en "," from locale ":" / opt / mattermost / i18n / en.json "}
{"level": "info", "ts": 1585379681.83874, "caller": "app / server_app_adapters.go: 58", "msg": "Server initializing ..."}
{"level": "info", "ts": 1585379681.8470004, "caller": "sqlstore / provider.go: 221", "msg": "Pinging SQL", "database": "master"}
{"level": "info", "ts": 1585379684.7858346, "caller": "sqlstore / upgrade.go: 112", "msg": "Database schema version has been set", "version": "5.21.0"}
{"level": "error", "ts": 1585379690.8182986, "caller": "app / server_app_adapters.go: 129", "msg": "SiteURL must be set. Some features will work incorrectly if SiteURL is not set. See documentation for more information: http://about.mattermost.com/default-site-url "}
{"level": "info", "ts": 1585379690.821083, "caller": "app / license.go: 39", "msg": "License key from https://mattermost.com required to unlock company features . "}

Then press CTRL + C to stop the Mattermost server.

Creating a Systemd Service File for Mattermost

Then you need to create a Systemd Service File to manage the Mattermost service. You can create it with the following command:

  nano /etc/systemd/system/mattermost.service tu 1919900919 Add the following lines: 

[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

Save and close the file when you are done. Then reload the system daemon with the following command:

  systemctl daemon-reload 

Then start the Mattermost service and activate it after system startup with the following command: Ads

Ads

  systemctl start mattermost 
systemctl enable mattermost

You can also verify the status of the Mattermost service with the following command: [19659008] systemctl status most important

You should get the following output:

? mattermost.service - Mattermost
Loaded: loaded (/etc/systemd/system/mattermost.service; disabled; vendor setting: disabled)
Active: active (running) since Sat 2020-03-28 03:17:07 EDT; 14th century ago
Head PID: 15204 (most important)
Details: 21 (limit: 25028)
Memory: 120.8M
CGroup: /system.slice/mattermost.service
?? 15204 / opt / mattermost / bin / mattermost
?? 15214 plugins / com.mattermost.nps / server / dist / plugin-linux-amd64

Mar 28 03:17:07 centos8 mattermost [15204]: {"level": "info", "ts": 1585379827.1131086, "caller": "app / server.go: 247", "msg": "Print Current work>
Mar 28 03:17:07 centos8 mattermost [15204]: {"level": "info", "ts": 1585379827.1131282, "caller": "app / server.go: 248", "msg": "Loaded config" "source">

The Mattermost server is currently running and listening on port 8065. You can check it with the following command:

  netstat -antup | grip 8065 

You should get the following output:

 tcp6 0 0 ::: 8065 ::: * LISTEN 15204 / mattermost

Configuring Nginx as a Reverse Proxy for Mattermost

It is a good idea to install and configure Nginx as a reverse proxy for better performance and security.

Install Nginx web server with the following command: [19659008] dnf install nginx-y

After installing the Nginx web server, start the Nginx service and enable it after system startup with the following command:

  systemctl start nginx 
systemctl enable nginx

Next, create a new virtual Nginx host file for Mattermost with the following command:

  nano /etc/nginx/conf.d/mattermost.confebrit19659009vardAdd the following lines: 

 upstream material list {
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] + / (user /)? 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;
remaining_timeout 5;
proxy_connect_timeout 90;
proxy_send_timeout 300;
proxy_read_timeout 90s;
proxy_pass http: // mattermost;
}
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 600 number;
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: // mattermost;
}
}

Save and close the file when you are done. Then check Nginx for syntax errors with the following command: Ads

  nginx -t 

You should get the following output:

 nginx : The /etc/nginx/nginx.conf syntax configuration file is ok
nginx: The /etc/nginx/nginx.conf test configuration file is successful

Finally, restart the Nginx service to apply the changes:

  systemctl restart nginx 

At this point, the Nginx web server is configured to serve Mattermost. You can now proceed to the next step.

Configuring SELinux and Firewalld

By default, SELinux is enabled in CentOS 8. It is recommended to disable it for Mattermost. You can disable it by editing / etc / selinux / config file:

  nano / etc / selinux / config 

Find the following line:

 SELINUX = maintain

And replace it with the following line:

 SELINUX = allowed

Save and close the file when you are done. Then restart the system to apply the changes.

Then you must allow port 80 through firewall. You can allow it with the following command:

  firewall-cmd --add-service = http --permanent 

Then load the firewall to apply the changes:

  firewall-cmd - reload 

Open Mattermost web interface

Now open your browser and type the URL http://mattermost.example.com . You should see the Matermost user page:

 Mattermost Installer

Enter your email address, username, password and click on Create account . You should see the following page:

 Create a team

Then click Create a new team to create your team. You should see the following page:

 Enter team name

Enter your team name and click the Next button. You should see the following page:

 Team URL

Enter your team URL and click on Finish to complete the installation. You should see the Mattermost dashboard on the following page:

 Mattermost Dashboard

Conclusion

Congratulations! you have installed and configured Mattermost on CentOS 8 server. You can now create a team for your organization and start collaborating with your team.


Source link