Setting up Mattermost on Ubuntu 18.04
Tags: devtools, opensource, mattermost, saas
Published: 2020-04-24 08:48:27

---
title: Setting up Mattermost on Ubuntu 18.04
published: true
date: 2020-04-24 07:49:49 UTC
tags: devtools,open-source,mattermost,saas
canonical_url: https://medium.com/innovation-incubator/setting-up-mattermost-on-ubuntu-18-04-939ef5af9f31
---

![](https://cdn-images-1.medium.com/max/1024/0*fhqGCAe-xic4b6FU)<figcaption>Source: <a href="https://mattermost.com/">mattermost.com</a></figcaption>

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](https://mattermost.com/download/) 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

![](https://cdn-images-1.medium.com/max/481/1*x7izlhW896CV6wEEVtOZHw.png)<figcaption>Signup page</figcaption>

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

![](https://cdn-images-1.medium.com/max/696/0*E4vmOI_-KH48rQOS)

Access System Console by clicking the go-to system console

![](https://cdn-images-1.medium.com/max/1024/1*T_NUbHeWce0Pxs2m9_NfVw.png)

Further configurations can be done reading through the [**Config Document**](https://docs.mattermost.com/administration/config-settings.html) **.**

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

* * *