Methods of payment Abuse

Installing and configuring Mattermost server on Ubuntu 24.04: a detailed guide.

  • Main
  • Knowledge base
  • Installing and configuring Mattermost server on Ubuntu 24.04: a detailed guide.
11.10.2024, 13:59

Description

Mattermost is an open source enterprise communication platform designed for internal communication of teams and organizations. It supports text chats, file sharing, video calls and integration with various third-party services. Mattermost can be deployed on your own servers for complete data control and security. It is an alternative to solutions such as Slack, with the ability to customize, automate and integrate with DevOps processes.

Requirements

1. A virtual server (VPS) with Ubuntu 24.04 installed.

2. Root permissions or an account with sudo.

3. (Optional) We strongly recommend using a proxy server before Mattermost to support up to 200 concurrent users. If you have less than 200 concurrent users, you can configure TLS. If you have more than 200 concurrent users, you will need a proxy server such as NGINX in front of Mattermost to manage traffic.

Step 1. Login to the server via SSH.

First, you need to connect to your server via SSH under the root user. Run the following command, replacing IP_Address with the IP address of your server and Port_number with the SSH port number:

ssh root@IP_Address -p Port_number

To make sure you have the correct version of Ubuntu installed, run the command:

lsb_release -a

Expected Outcome:

Distributor ID: Ubuntu
Description:     Ubuntu 24.04 LTS
Release:            24.04
Codename:      noble

Step 2: Install and configure the database.

Updating the OS:

apt update
apt upgrade

Now let's create a PostgreSQL database for use by the Mattermost server. Enter the command (this command will install postgresql):

apt install postgresql

Let's go to PostgreSQL:

sudo -u postgres psql

Create a Mattermost base:

CREATE DATABASE mattermost;

Create the mmuser user (instead of the mmuser-password we use a more secure password):

CREATE USER mmuser WITH PASSWORD 'mmuser-password';

Authorize the mmuser user:

GRANT ALL PRIVILEGES ON DATABASE mattermost to mmuser;
GRANT ALL ON DATABASE mattermost TO mmuser;
ALTER DATABASE mattermost OWNER TO mmuser;
GRANT USAGE, CREATE ON SCHEMA PUBLIC TO mmuser;

Exit PostgreSQL

\q

Make changes to the pg_hba.conf file giving the Mattermost server access to the PostgreSQL database. Open the file:

nano /etc/postgresql/16/main/pg_hba.conf

We find the lines:

local   all             all                                                  peer
host    all             all             127.0.0.1/32            scram-sha-256
host    all             all             ::1/128                       scram-sha-256

Replace with:

local   all             all                                                  trust
host    all             all             127.0.0.1/32            trust
host    all             all             ::1/128                       trust

Save the changes, close the file and update the PostgreSQL configuration:

systemctl reload postgresql

Check that we can connect to the database from the mmuser user:

psql --dbname=mattermost --username=mmuser --password

Enter the password we created instead of mmuser-password.

If we have done everything correctly - the PostgreSQL mattermost=> console will appear.

Let's get out:

\q

Step 3. Download and install the Mattermost server.

Download the latest version of Mattermost server:

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

Unpacking:

tar -xvzf mattermost*.gz

Move it to the /opt directory:

mv mattermost /opt

By default, the Mattermost server uses the /opt/mattermost/data directory.

Let's create it:

mkdir /opt/mattermost/data

Now let's create a group and user mattermost:

useradd --system --user-group mattermost

We'll give you your license:

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

Step 4: Create a system service.

To manage the Mattermost server, let's create a system service.

Open the editor to create the service file:

nano /lib/systemd/system/mattermost.service

Fill the opened, empty file with the following content:

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

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

[Install]
WantedBy=multi-user.target

Update the systemd configuration:

systemctl daemon-reload

Before starting the Mattermost server, you must configure it.

Back up the configuration file:

cp /opt/mattermost/config/config.json /opt/mattermost/config/config.defaults.json

Open the Mattermost server configuration file in a text editor:

nano /opt/mattermost/config/config.json

We need to make a change.

Find it:

"DataSource": "postgres://mmuser:@localhost/mattermost_test?sslmode=disable\u0026connect_timeout=10\u0026binary_parameters=yes"

Replace with:

"DataSource to "postgres://mmuser: <mmuser-password>@<host-name-or-IP>:5432/<mattermost>?sslmode=disable&connect_timeout=10"

Where

<mmuser-password> - mmuser password for PostgreSQL.

<host-name-or-IP> - IP address of the server or its hostname.

<mattermost> - PostgreSQL database.

Save the file and exit the editor.

Activate the service to run at system startup and start it now:

systemctl enable --now mattermost

To check the status of the server, use the command:

systemctl status mattermost

Step 5: Connect to the Mattermost server.

Open <IP address of your server or its hostname> in the browser: 8065

Follow the instructions on the page that opens.

   

Conclusion

Mattermost server is now installed and running on your Ubuntu 24.04 server.