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.
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
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
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
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
Open the <IP address of your server or its hostname>
in a browser : 8065
Follow the instructions on the page that opens.
Mattermost server is now installed and running on your Ubuntu 24.04 server.