How to Deploy Mattermost on Ubuntu 20.04

Wondering how to deploy Mattermost on Ubuntu 20.04 LTS?

Mattermost provides its users a safe messaging environment by relying on a free-to-use, community-powered system, which allows for secure collaboration. 

It lets you utilize all the advantages of the workplace environment on an external web-based information sharing platform. Moreover, the software integrates webhooks and bots, which provides additional customization. It is compatible with all major PC operating systems, including Linux, and even iOS and Android.

These features make Mattermost a good alternative to SaaS messaging for teams.

If you’re someone who wishes to learn how to deploy Mattermost in Ubuntu 20.04 LTS, then this guide is meant for you. Just follow the steps in this guide to ensure a seamless installation.

So without further ado, let’s begin!

Step 1: Updating your System.

The first step is to make sure that your system is updated. This will ensure that there are no problems caused by outdated repositories.

Although this guide uses Ubuntu 20.04 LTS, the process isn’t any different from its previous versions.

To update your system packages and repositories, follow these steps:

  1. First, open the Command Terminal by pressing Ctrl + Alt + T  on your keyboard.
  2. Next, execute the following:
$ sudo apt update && sudo apt upgrade
Deploy Mattermost on Ubuntu

This will update all packages to the latest available versions. With this, you can proceed to the next step.

Step 2: Setting up the Hostname.

The next step is to set an appropriate hostname for your server, along with installing a reliable database.

Enter the following in the Command Terminal to set up the hostname:

$ sudo hostnamectl set-hostname <Hostname> --static

For example,

$ sudo hostnamectl set-hostname test.ubuntu --static
Deploy Mattermost on Ubuntu

Step 3: Setting up the Database.

Once that’s done, proceed to set up the database.

It is recommended that you make use of PostgreSQL. However, MySQL is also a reliable alternative.

Follow these steps to set up the database:

  1. First, open the Command Terminal.
  2. Next, type the following:
$ sudo apt install postgresql postgresql-contrib
Deploy Mattermost on Ubuntu
  1. After that, type the following to log in to your database account:
$ sudo --login --user postgres
Deploy Mattermost on Ubuntu
  1. Now, start PostgreSQL and create a user/database for Mattermost. For this purpose, use this command:
$ psql
sudo
$ CREATE DATABASE mattermost;
Deploy Mattermost on Ubuntu

Once that’s done, type the following commands:

$ CREATE USER <username> WITH PASSWORD ‘<password>’;

For example,

$ CREATE USER ubuntu20 WITH PASSWORD ‘ubuntu2021’;

$ GRANT ALL PRIVILEGES ON DATABASE mattermost TO ubuntu20;

$ \q;
privileges

These commands will create a user profile that has full access to the Mattermost database.

Step 4: Creating a Mattermost group and user.

After setting up the PostgreSQL database, you’re halfway there in learning how to deploy Mattermost on Ubuntu 20.04 LTS.

The next step is to create a new user and group titled “mattermost”. For this purpose, you’ll use the $ useradd command.

Follow these steps to add a new user and group:

  1. To start, open the Command Terminal by pressing Ctrl + Alt + T on your keyboard.
  2. Next, type the following:
$ sudo useradd --system --user-group mattermost

This will create a new user and group titled “mattermost” that has system privileges.

  1. Lastly, confirm the creation by typing the following:
$ id mattermost

You should get an output similar to the image below.

mattermost

With the steps followed correctly, you should now have created a user and group titled “mattermost” on your system. 

Step 5: Installing and Configuring Mattermost.

Now that the prerequisites are finally completed, you can proceed to install Mattermost on your system. 

This involves a simple process that makes use of the Command Terminal.

Follow these steps to install Mattermost on your system:

  1. Start by creating a directory for Mattermost by typing the following in the Command Terminal:
$ mkdir mattermost
  1. Next, change the directory to “mattermost” by typing the following command:
$ cd mattermost
mkdir
  1. Afterward, execute the following in the Command Terminal to get the latest version of the software:
$ wget https://releases.mattermost.com/<X.X.X>/mattermost-<X.X.X>-linux-amd64.tar.gz

At the time of writing this guide, the latest available version is 4.7.2, so the command would be:

$ wget https://releases.mattermost.com/4.7.2/mattermost-4.7.2-linux-amd64.tar.gz
linux
  1. Once the download is finished, extract the package by typing the following:
$ tar -xvzf mattermost*.gz
mattermost ubuntu
  1. Next, make a copy of the file and place it in the /otp directory. You can do so by using this command:
$ sudo cp -r mattermost /opt
mattermost
  1. Make a new folder that will store data related to Mattermost by typing the following command:
$ sudo mkdir/opt/mattermost/data
  1. Lastly, give appropriate permissions by typing the following in the Terminal:
$ sudo chown -R mattermost:mattermost /opt/mattermost

$ sudo chmod -R g+w /opt/mattermost

With the steps followed correctly, you should now have installed and configured Mattermost on your system.

Step 6: Configuring the Mattermost Server.

With Mattermost set up and ready for use, all that’s left is to configure the server. An in-depth explanation of deploying the Mattermost server is available in their official user manual.

Mattermost can also be configured to have backups, ensuring that there’s no data loss in case of a server crash. These backups can be configured to either save minimal data necessary for the server to function correctly or do a complete, automated failsafe.

When you’re working with Mattermost, having applications that can function as an appropriate load-balancer can turn out to be a game-changer. Plus, having dedicated software responsible for managing data traffic and user interaction with the website can provide your server the edge it needs for efficient web hosting.

For this purpose, we recommend that you install and configure Nginx on your system.

We hope this guide helped you learn how to deploy Mattermost on Ubuntu 20.04 LTS. If you have any questions or suggestions to make this guide better, let us know in the comment section down below.

If this guide helped you, please share it. 🙂

Author

Leave a Reply

Your email address will not be published. Required fields are marked *