How to install Mattermost on RHEL 7.1

Mattermost

Introduction

Mattermost is an open source, private cloud Slack-alternative. A workplace messaging system for web, PCs and phones, released under the MIT license.
In a previous tutorial we talked about how to install it on Ubuntu 16.04.
Now, let’s see how to install and configure Mattermost on a RHEL 7.1 machine using MySQL as the database.

Install Database

On the server, download MySQL 5.7 executing the following command:

# wget http://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm

and install the yum repository from that file with:

# yum localinstall mysql57-community-release-el7-9.noarch.rpm

Next, install MySQL:

# yum install mysql-community-server

and start it:

# systemctl start mysqld

After executing this command for the first time, MySQL will generate a temporary password for the root account. To retrieve it, just:

# grep 'temporary password' /var/log/mysqld.log

This command will output something like this:

2017-03-02T08:21:27.969295Z 1 [Note] A temporary password is generated for [email protected]: Ed4SxpDyuH(y

Change the root password. First, login as root:

# mysql -u root -p

Enter the temporary password.
Next, in the MySQL shell:

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'my_new_root_strong_password';
mysql> EXIT;

Set MySQL to start automatically at boot time:

# chkconfig mysqld on

Start the MySQL shell again:

# mysql -u root -p

Entering the new root password, create a user for Mattermost and a new database:

mysql> CREATE USER 'mmuser'@'localhost' IDENTIFIED BY 'mmuser_strong_password';
mysql> CREATE DATABASE mattermostdb;
mysql> GRANT ALL PRIVILEGES ON mattermostdb.* TO 'mmuser'@'localhost';
mysql> FLUSH PRIVILEGES;
mysql> EXIT;

Install Mattermost Server

Download the latest release of Mattermost Server. For example only, at the time we are writing:

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

Extract the archive, and move the ‘mattermost’ folder to /opt

# tar xf *.gz
# mv mattermost /opt/

Create a directory for storage files:

# mkdir /opt/mattermost/data

Make sure that the drive is large enough to hold the anticipated number of uploaded files and images that will be stored on data.
Next, set up a user and group, both named ‘mattermost’, and set the ownership and permissions:

# useradd --system --user-group mattermost
# chown -R mattermost:mattermost /opt/mattermost
# chmod -R g+w /opt/mattermost

Set up the database driver through the /opt/mattermost/config/config.json file. In it, search for “DriverName” and “DataSource” lines and change as follows:

"DriverName": "mysql"
"DataSource": "mmuser:@tcp(localhost:3306)/mattermost?charset=utf8"
Save, exit, and test the Mattermost Server with the following command:
# sudo -u mattermost /opt/mattermost/bin/platform

If everything works, it should output Server is listening on :8065 . Interrupt it with CTRL+C.

Create a systemd unit.

Create a systemd file for Mattermost, /etc/systemd/system/mattermost.service and, in it, paste the following configuration:

[Unit]
Description=Mattermost
After=syslog.target network.target postgresql-9.4.service

[Service]
Type=simple
WorkingDirectory=/opt/mattermost/bin
User=mattermost
ExecStart=/opt/mattermost/bin/platform
PIDFile=/var/spool/mattermost/pid/master.pid
LimitNOFILE=49152

[Install]
WantedBy=multi-user.target

Make it executable:

# chmod 664 /etc/systemd/system/mattermost.service

And reload the services:

# systemctl daemon-reload

Enable Mattermost service:

# chkconfig mattermost on

And start it with systemd:

# systemctl start mattermost

Check if it’s running visiting the URL http://localhost:8065.

Install and configure NGINX

Installation

In a production system, use a proxy server in front of Mattermost Server. In this case, NGINX.
The main benefits of doing this are:

  • SSL termination
  • Port mapping :80 to :8065
  • HTTP to HTTPS redirect
  • Standard request logs

In order to install NGINX on RHEL 7.1, create a yum repository file, /etc/yum.repos.d/nginx.repo, with the following content:

[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/rhel/7.1/$basearch/
gpgcheck=0
enabled=1

Save, exit and install NGINX with yum:

# yum install nginx.x86_64

Start NGINX and test it:

# systemctl start nginx
Configuration

In order to configure NGINX as proxy server, create the file /etc/nginx/sites-available/mattermost and past:

upstream backend {
   server localhost:8065;
}

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.mydomain.com;

   location /api/v3/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://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_pass http://backend;
   }
}

Remove the existing default site-enabled file with:

# rm /etc/nginx/sites-enabled/default

and enable Mattermost:

# ln -s /etc/nginx/sites-available/mattermost /etc/nginx/sites-enabled/mattermost

Restart NGINX:

# systemctl restart nginx

Conclusions

At the end of this process, the server should be up and running. With a web browser go to URL http://mattermost.mydomain.com and continue to configure Mattermost by entering an email address and creating an account.
That’s all! The server is ready to serve as your messaging system!

  • I’ve made 104000 dollars previous year by freelancing on-line a­­n­­d I was able to do it by w­o­r­k­i­n­g in my own time f­­o­­r several hours each day. I used work opportunity I stumbled upon online and I am excited that i made so much money on the side. It’s very user-friendly and I’m so thankful that i discovered it. This is what i did… http://www.wzurl­.­me/tEXzrw

  • bell_raymond

    I profited 104 thousand dollars in 2016 by working online from home and I manage to do it by working part-time f­o­r 3+ h each day. I used an earning model I came across from company that i found online and I am thrilled that i was able to make so much extra income. It’s very user-friendly and I’m just so happy that i discovered it. Check out what I did… http://urlof­.­site/gK5Tu

  • [email protected]

    I was paid 104000 dollars past year by doing an internet task and consequently I was able to do it by w­orking in my own time f­o­r quite a few hours each day. I tried work opportunity I stumbled upon on the internet and also I am excited that I was in the position to make such good money. It’s undoubtedly newbie-friendly and therefore I’m so blessed that I found out about it. Read through what I do… I was without work for six months when my early Co-worker lastly strongly recommended me to begin freelancing online… It was actually after I gained $5000 in my first thirty days when I actually believed I could do this for a living! At the moment I am happier than ever… I work-from-home moreover I am my own boss now that I always wanted… I see several unhappy people around me, working the same old boring job that is sucking the everyday life from them day-after-day… Whenever I see some-one like that I say START FREELANCING MAN! This is where I started off >>>> www­.­cat­.­org­.­uk/snip/78276

  • [email protected]

    I was paid 104000 bucks past 12 months by doing a web based job furthermore I was able to do it by w­orking in my own time f­o­r quite a few hours everyday. I utilized work opportunity I found out on the web and I am thrilled that I was manage to make such decent money. It’s really newbie-friendly and I’m so delighted that I found out regarding it. Look into what I do… www­.­cat­.­org­.­uk/snip/93439

  • lawrence_lee

    I was paid 104000 bucks past 12 months by doing an online task and I was able to do it by w­orking in my own time f­o­r quite a few hours every day. I used job opportunity I stumbled upon on the internet and also I am excited that I was manage to make such decent money. It is undoubtedly newbie-friendly and I’m so delighted that I found out regarding it. Go and visit what I do… http://polr­.­me/1g1h

  • I was paid 104000 dollars previous 12 month period by doing a web based task moreover I was able to do it by w­orking in my own time f­o­r several hours everyday. I used job opportunity I found on the net and also I am excited that I was in the position to make such great money. It is genuinely newbie-friendly and I am so delighted that I found out regarding it. Look into exactly what I do… http://ipt­.­pw/A26DTk

  • mobley.barbara

    I was without work for six months time when my former Fellow worker at last recommended me to begin freelancing at home… It was only just after I received $5000 in my first thirty days when I seriously believed I could do this for a living! Currently I am delightful than ever… I work at home and also I am my own boss now like I always wanted… I see so many unhappy people around me, working the same old boring job that is sucking the daily life from them day-after-day… Everytime I see anybody similar to that I say START FREELANCING MAN! This is how I started out >>>> http://flicom­.­ru/955876

  • I was paid 104000 bucks past 12 months by doing an online work furthermore I was able to do it by w­orking in my own time f­o­r several hours every day. I utilized work opportunity I found out online and I am delighted that I was manage to make such decent earnings. It is seriously newbie-friendly and therefore I’m so blessed that I found out about it. Find out more about exactly what I do… http://olaurl­.­com/15cnp

  • Owner of MSN!, is telling individuals to get into “Work at home” practice, that I have already been doing for more than 12 months now. This season alone, I made around $36k up till now with no more than my home computer and some leisure time, even though i have a fulltime 9 to 5 job. Even everyone new to this, can earn $50/per h successfully and the earnings may go even very high with time… This is how i started >> http://adultadda­.­net/2Y4

  • M­a­n­y p­e­o­ple w­a­nt t­o ha­v­e a passive in­com­e at h­o­me, bu­t t­he­y don’t have much idea ho­w t­o exactly d­o th­at o­n th­e Int­ernet. Th­ere ar­e a many w­ays t­o ea­rn big am­ount of mo­ney, b­ut wh­enev­er p­eopl­e t­ry th­at the­y g­et tr­app­ed in a fraud, So I am sh­aring wi­th yo­u a g­enuine an­d gu­arante­ed w­ay f­or fre­e to ea­rn hug­e am­ount of mon­ey a­t ho­me.I am making atleast $10000 monthly since 1 year.Its an internet based job and so easy to do, Even a little boy or girl can do this work and make money on the internet. If you want a happy and wealthy life then you should copy and paste this website in web browser and then follow instructions to get started today and make Thousands Using the internet……….. http://ipt­.­pw/utWCom

  • M­a­n­y p­e­o­ple desire t­o ha­v­e a go­o­d in­com­e at h­o­me, bu­t t­he­y do­n’t kno­w ho­w t­o exactly d­o th­at o­n th­e Int­ernet. Th­ere ar­e a l­ot of w­ays t­o ea­rn big am­ount of mo­ney, b­ut wh­enev­er p­eopl­e t­ry th­at the­y g­et tr­app­ed in a fraud, Therefore I am sh­aring wi­th yo­u a g­enuine an­d gu­arante­ed w­ay f­or fre­e to ea­rn hug­e am­ount of mon­ey a­t ho­me.I am earning atleast $10000 every month since 12 months.Its an internet based job and super easy to do, Even a little child can do this work and make money on the internet. If you want a happy and wealthy life then you need to copy and paste this site in web browser and then follow instructions to get started today and make Thousands On the internet……….. http://b1z­.­org/38Z

  • If you’re seek legit on-line home-based business advertising opportunity but you are exhausted by internet scammers then this is actually what you were searching for. I started out working on this project couple of yrs now and receiving Seven Thousand dollars or over each mnth quite easily. Start receiving funds like me… Have a look at details >>>>>>>>>>> http://v15­.­uk/j93OB

  • Earning via the web is just as very easy (as well as tough) such as earning money offline. While hundreds upon hundreds of Web marketing gurus guarantee to currently have a hidden knowledge model making quick earnings, the fact is, it does not use any opportunity that you can emerge as wealthy person over night by just clicking a button or simply selecting various e book. Generating revenue on line require working hard as well as dedication. Whenever you are in a position to give time as well as strength involved, there are plenty of strategies to making high income using the web.I am obtaining $10000 or maybe higher month-to-month using this job.Here is the quick way to make profit while the rest are very long internet money making ideas >>>>> OUOURL.COM/4rh9