loading...
Innovation Incubator

Setting up Mattermost on Ubuntu 18.04

nhadiq97 profile image NAEEM HADIQ Originally published at Medium on ・4 min read

Source: mattermost.com

In the present scenario of Lockdowns and work from home, Companies are investing heavily in online tools. But let's look at the opensource Toolkits that can aid in working from home maybe even better than the paid counterparts.

Mattermost-Open Source Slack Alternative

As we all know Slack being the new best choice for startups and enterprises alike for in company and in team communications. Mattermost is an opensource equivalent with a lesser attractive UI but the same functionalities.

Lets Set up a Mattemost self-hosted Server

This can either be done on the cloud(such as AWS)or on-premise. The hardware requirements are so low that an EC2 t2.micro can handle around 100 users. If on cloud configure port 80,443 to accept all inbound requests and 22 for your configuration SSH.

Step 1- Upgrade and Update the system

sudo apt update
sudo apt -y upgrade
sudo apt -y install wget curl vim

It is recommended to reboot after an upgrade

sudo reboot

The Next Step is to set a proper Domain name configured

sudo hostnamectl set-hostname chat.example.com --static

Step 2- install the DB

Mattermost supports SQL and Postgress. For the Purpose of the tutorial, let's go ahead with Postgres for reliability and scale.

sudo apt -y install postgresql postgresql-contrib

Since Postgres automatically starts up after an install.Login with Postgres account

sudo --login --user postgres

Start the PostgreSQL interactive terminal and create the Mattermost database/user ‘ mmuser ’ grant necessary rights and exit Postgres account.

psql
CREATE DATABASE mattermost;
CREATE USER mmuser WITH PASSWORD 'StrongDBPassWord';
GRANT ALL PRIVILEGES ON DATABASE mattermost to mmuser;
\q
exit

Step 3: Create Mattermost user and group

sudo useradd --system --user-group mattermost

This creates a system user .

Step 4: Download and install Mattermost

With the database server configured, you can now download and install Mattermost. First, visit the Mattermost downloads page to get the latest release.

Assuming the Latest release is 5.22.1

wget [https://releases.mattermost.com/5.22.1/mattermost-5.22.1-linux-amd64.tar.gz](https://releases.mattermost.com/5.22.1/mattermost-5.22.1-linux-amd64.tar.gz)

if the Version changes replace x.x.x with the corresponding version and use the link

wget [https://releases.mattermost.com/x.x.x/mattermost-x.x.x-linux-amd64.tar.gz](https://releases.mattermost.com/5.22.1/mattermost-5.22.1-linux-amd64.tar.gz)

Now extract the downloaded package

tar xvf mattermost-5.22.1-linux-amd64.tar.gz

Move the extracted file to the /opt directory.

sudo mv mattermost /opt

Next step is to create a directory to store user files

sudo mkdir /opt/mattermost/data

Set correct ownership and permissions

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

Step 5: Configuring the Mattermost server

The config file of Mattermost server is accessible at /opt/mattermost/config/config.json

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

Configure PostgreSQL database settings to look like below under “ SqlSettings “: section.

"DriverName": "postgres",
"DataSource": "postgres://mmuser:StrongDBPassWord@localhost:5432/mattermost?sslmode=disable&connect\_timeout=10",

“Service Settings”: “” Section Alter the corresponding values This assumes that you are going to use LetsEncrypt for SSL

"SiteURL": "chat.example.com"

Listen port

"ListenAddress":":443"
"ConnectionSecurity":"TLS"
"UseLetsEncrypt":true
"Forward80To443":true

Security

"ConnectionSecurity":"TLS"

enabling Lets Encrypt alternate to enable this you can use your self signed certificate by entering appropriate data in fields

"UseLetsEncrypt":true

HTTP to Https redirect

"Forward80To443":true

Enabling Mattermost to bind to lower ports

sudo setcap cap\_net\_bind\_service=+ep /opt/mattermost/bin/platform

Step 6: Configure Systemd Service

Create Mattermost Systemd service unit.

$ sudo vim /etc/systemd/system/mattermost.service

Populate the below data into the file.

[Unit]
Description=Mattermost
After=network.target
After=postgresql.service
Requires=postgresql.service

[Service]
Type=notify
ExecStart=/opt/mattermost/bin/platform
TimeoutStartSec=3600
Restart=always
RestartSec=10
WorkingDirectory=/opt/mattermost
User=mattermost
Group=mattermost
LimitNOFILE=49152

[Install]
WantedBy=multi-user.target

Make systemd load the new unit.

sudo systemctl daemon-reload

Start and Enable Mattermost Service

sudo systemctl start mattermost.service
sudo systemctl enable mattermost.service

Check service status to make sure it is running.

systemctl status mattermost.service

Verify that Mattermost is running by calling the link on a browser assuming that you have already pointed the DNS.

[https://chat.example.com](http://chat.example.com)

would return an HTML returned by the server.

Step 7: Finish Mattermost Web configuration

Signup page

Note that the initial signup user would be the default system admin

Access System Console by clicking the go-to system console

Further configurations can be done reading through the Config Document .

You are all set to start utilizing the self-hosted Mattermost server.


Posted on by:

nhadiq97 profile

NAEEM HADIQ

@nhadiq97

A Tech Evangelist with immense greed to learn and network.

Innovation Incubator

We publish various articles on the latest technologies.

Discussion

markdown guide
 

Naeem, can you say if users like MM more than Slack?
What is the maintenance like?
I'm pondering if MM would be a good option for us.

 

Hi Max,
Most users won't find a difference between them except for the minor UI Changes. With regard to maintenance, its almost configure once and forget, It's also fairly easy to update. Kindly use S3 Bucket for storage instead of ebs if ur running this for the team .
Would be happy to help if you need any support.