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

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 like Slack, with the ability to customize, automate and integrate with DevOps processes.

Requirements

  1. Virtual server (VPS) with Ubuntu 24.04 installed.
  2. Root privileges 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 Result:

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

Step 2: Install and configure the database.

Upgrade the OS:

apt update
apt upgrade

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

apt install postgresql

Log into PostgreSQL:

sudo -u postgres psql

Create a Mattermost database:

CREATE DATABASE mattermost;

Create the mmuser user (use a more secure password instead of mmuser-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;

Log out of PostgreSQL

q

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

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

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 console will appear.

Exit:

q

Step 3: Download and install 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

Unzip:

tar -xvzf mattermost*.gz

Transfer to the /opt directory:

mv mattermost /opt

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

Create it:

mkdir /opt/mattermost/data

Now create a group and user mattermost:

useradd --system --user-group mattermost

Grant permissions:

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 a service file:

nano /lib/systemd/system/mattermost.service

The opened, empty file - fill it with the following contents:

[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 running the Mattermost server, you must configure it.

Create a backup copy of 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 the changes.

Find:

"DataSource": "postgres://mmuser:@localhost/mattermost_test?sslmode=disableu0026connect_timeout=10u0026binary_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

Use the command to check the server status:

systemctl status mattermost

Step 5: Connect to the Mattermost server.

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

Follow the instructions on the page that opens.

Conclusion

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