YouTube Icon

Code Playground.

How to deploy Mattermost on CentOS 7

CFG

How to deploy Mattermost on CentOS 7

Mattermost is an open-source, texting stage, a self-facilitated Slack other option. It's written in Golang and React and can utilize MySQL or PostgreSQL as an information base backend. Mattermost brings all your group correspondence into one spot and gives different highlights including record sharing, one-on-one and gathering informing, custom emoticons, video calls and then some. In this instructional exercise, we will tell you the best way to send Mattermost on a CentOS 7 worker and design Nginx as a SSL turn around intermediary. 

Prerequisites

Ensure that you have met the accompanying essentials prior to proceeding with this instructional exercise: 

You are signed in as a client with sudo advantages . 

You have a space name highlighting your worker IP address. We will utilize linuxize-test.com. 

You have Nginx introduced, if not check this guide. 

You have a SSL declaration introduced for your area. You can introduce a free Let's Encrypt SSL authentication by following this guide. 

Create MySQL Database

We will utilize MariaDB 10.3 as an information base back-end. Mattermost won't work with MariaDB rendition 5.5. 

On the off chance that you don't have MariaDB 10.3 introduced on your worker you can check this guide . 

Login to the MySQL shell: 

mysql -u root -p

Furthermore, run the accompanying orders to make another information base and client for our Mattermost establishment: 

create database mattermost;
GRANT ALL ON mattermost.* TO mattermost@localhost IDENTIFIED BY 'P4ssvv0rD';

Create new system user

To make another client and gathering named mattermost, which will run the Mattermost establishment, run the accompanying order: 

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

Install Mattermost Server

At the hour of composing this article, the most recent stable form of Mattermost is variant 5.4.0. Prior to proceeding with the following stage you should check the Mattermost download page to check whether a fresher form is accessible. 

Download the chronicle with the accompanying twist order : 

sudo curl -L https://releases.mattermost.com/5.4.0/mattermost-5.4.0-linux-amd64.tar.gz -o /tmp/mattermost.tar.gz

Once the download is finished concentrate the file and move it to the select registry: 

sudo tar zxf /tmp/mattermost.tar.gz -C /opt

Make the capacity catalog for records: 

sudo mkdir /opt/mattermost/data

Change the registry proprietorship to the mattermost client: 

sudo chown -R mattermost: /opt/mattermost

Open the config.json document with your #1 content manager : 

sudo nano /opt/mattermost/config/config.json

Set the information base driver to mysql, enter the data set name and information base client secret word that we made before in this instructional exercise: 

/opt/mattermost/config/config.json

...
"SqlSettings": {
    "DriverName": "mysql",
    "DataSource": "mattermost:P4ssvv0rD@tcp(localhost:3306)/mattermost?charset=utf8mb4,utf8&readTimeout=30s&writeTimeout=30s",
    "DataSourceReplicas": [],
...

To test our establishment to ensure all that works prior to making systemd unit and setting up an opposite intermediary with Nginx we will begin the Mattermost worker. 

Change into the/select/mattermost index and start the worker : 

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

The yield should show that the Mattermost worker is tuning in on port 8065 : 

{"level":"info","ts":1540921243.6797202,"caller":"app/plugin.go:100","msg":"Starting up plugins"}
{"level":"info","ts":1540921244.3483207,"caller":"app/server.go:88","msg":"Starting Server..."}
{"level":"info","ts":1540921244.3488805,"caller":"app/server.go:148","msg":"Server is listening on [::]:8065"}
{"level":"info","ts":1540921244.3620636,"caller":"app/web_hub.go:75","msg":"Starting 2 websocket hubs"}
{"level":"info","ts":1540921244.451155,"caller":"jobs/workers.go:63","msg":"Starting workers"}
{"level":"info","ts":1540921244.456804,"caller":"jobs/schedulers.go:68","msg":"Starting schedulers."}

You would now be able to stop the Mattermost worker with CTRL+C and proceed with the following stages. 

Create a Systemd Unit

To run our Mattermost occasion as a help we will make a mattermost.service unit document in the/and so forth/systemd/framework/registry with the accompanying substance: 

/etc/systemd/system/mattermost.service

[Unit]
Description=Mattermost
After=network.target nss-lookup.target mariadb.service

[Service]
Type=notify
WorkingDirectory=/opt/mattermost
User=mattermost
SyslogIdentifier=mattermost
ExecStart=/opt/mattermost/bin/mattermost
TimeoutStartSec=3600
LimitNOFILE=49152

[Install]
WantedBy=multi-user.target

Advise systemd that we made another unit record and start the Mattermost administration by executing: 

sudo systemctl daemon-reload
sudo systemctl start mattermost

We would now be able to check the administration status with the accompanying order: 

sudo systemctl status mattermost
? mattermost.service - Mattermost
   Loaded: loaded (/etc/systemd/system/mattermost.service; disabled; vendor preset: disabled)
   Active: active (running) since Tue 2018-10-30 17:44:46 UTC; 3s ago
 Main PID: 25959 (mattermost)
   CGroup: /system.slice/mattermost.service
           ??25959 /opt/mattermost/bin/mattermost

At long last, empower the Mattermost administration to be naturally begun at boot time: 

sudo systemctl enable mattermost

Set Up a Reverse Proxy with Nginx

On the off chance that you followed our how to introduce Nginx on CentOS 7 and how to protect Nginx with Let's Encrypt on CentOS 7 aides you should as of now have Nginx introduced and arranged with SSL endorsement. Presently we just need to make another worker block for our Mattermost establishment. 

/etc/nginx/conf.d/linuxize-test.com.conf

proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=mattermost_cache:10m max_size=3g inactive=120m use_temp_path=off;

upstream mattermost_backend {
  server 127.0.0.1:8065;
}

server {
    listen 80;
    server_name linuxize-test.com www.linuxize-test.com;

    include snippets/letsencrypt.conf;
    return 301 https://linuxize-test.com$request_uri;
}

server {
    listen 443 ssl http2;
    server_name www.linuxize-test.com;

    ssl_certificate /etc/letsencrypt/live/linuxize-test.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/linuxize-test.com/privkey.pem;
    ssl_trusted_certificate /etc/letsencrypt/live/linuxize-test.com/chain.pem;
    include snippets/ssl.conf;

    return 301 https://linuxize-test.com$request_uri;
}

server {
    listen 443 ssl http2;
    server_name linuxize-test.com;

    ssl_certificate /etc/letsencrypt/live/linuxize-test.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/linuxize-test.com/privkey.pem;
    ssl_trusted_certificate /etc/letsencrypt/live/linuxize-test.com/chain.pem;
    include snippets/ssl.conf;

    access_log /var/log/nginx/linuxize-test.com-access.log;
    error_log /var/log/nginx/linuxize-test.com-error.log;

   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;
       proxy_read_timeout 600s;
       proxy_pass http://mattermost_backend;
   }

   location / {
       proxy_http_version 1.1;
       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_pass http://mattermost_backend;
   }
}

Reload the Nginx administration for changes to produce results: 

sudo systemctl reload nginx

Configuring Mattermost

Open your program, type your space and make your first record: 

The originally made client in the framework has overseer advantages. 

Snap on Create another group interface, make your first group, and set the group URL: 

After you make the main director account and the principal group you will be diverted to the Mattermost dashboard, signed in as a chairman. Open the System Console, by tapping on your username at the highest point of the route board, and in the new menu that opens, click on the System Console interface: 

Set the site URL by going to Settings General → Configuration. 

Empower email warnings by going to Notifications → Email 

furthermore, enter your SMTP boundaries. You can utilize any well known conditional email administrations, for example, SendinBlue, SendGrid, Amazon SES, Mandrill, Mailgun, Mailjet, and Postmark or you can set up your own mail worker . 

At long last, we need to restart the Mattermost administration for changes to produce results: 

sudo systemctl restart mattermost

Conclusion

You have effectively introduced Mattermost on your CentOS 7 worker and arrangement Nginx as an opposite intermediary. You would now be able to begin utilizing Mattermost to work together with your group. 

In the event that you are confronting any issue with the establishment, don't hesitate to leave a remark.




CFG