How to Install Mattermost on Ubuntu VPS
How to Install Mattermost on Ubuntu 20.04/22.04 with AvaHost
Mattermost is a secure, open-source messaging platform, a self-hosted alternative to Slack, ideal for privacy-focused teams. This guide simplifies installing Mattermost on an AvaHost Ubuntu 20.04/22.04 VPS or dedicated server, with practical examples and tips for a scalable, secure setup.
Introduction
Mattermost offers robust collaboration tools with full data control, perfect for organizations needing privacy and scalability. With AvaHostās high-performance VPS and NVMe storage, you can deploy a reliable Mattermost instance for real-time team communication.
Prerequisites
Before starting, make sure you have:
- A VPS or dedicated server running Ubuntu 20.04 or 22.04
- Root privileges or sudo access
- A domain name (optional but recommended)
- Installed packages: PostgreSQL, NGINX, curl, wget, and unzip
Step 1: Install PostgreSQL
Mattermost requires PostgreSQL for data storage.
sudo apt update
sudo apt install postgresql postgresql-contrib -yCreate the database and user for Mattermost:
sudo -u postgres psqlInside the PostgreSQL shell:
CREATE DATABASE mattermost;
CREATE USER mmuser WITH PASSWORD 'strongpassword';
GRANT ALL PRIVILEGES ON DATABASE mattermost TO mmuser;
\qStep 2: Download and Install Mattermost
Navigate to the /opt directory:
cd /optDownload the latest version of Mattermost:
wget https://releases.mattermost.com/X.X.X/mattermost-X.X.X-linux-amd64.tar.gzReplace
X.X.Xwith the latest version number, e.g.,
9.5.2.
Extract the archive:
tar -xvzf mattermost-*.tar.gz
sudo mv mattermost /opt
sudo mkdir /opt/mattermost/dataStep 3: Configure Mattermost
Open the configuration file:
sudo nano /opt/mattermost/config/config.jsonLocate the database settings and update the connection string:
"SqlSettings": {
"DriverName": "postgres",
"DataSource": "postgres://mmuser:strongpassword@localhost:5432/mattermost?sslmode=disable",Save and exit.
Step 4: Create System User and Systemd Service
Create a dedicated system user:
sudo useradd --system --user-group mattermost
sudo chown -R mattermost:mattermost /opt/mattermostCreate a systemd unit file:
sudo nano /lib/systemd/system/mattermost.serviceInsert the following content:
[Unit]
Description=Mattermost
After=network.target>[Service]
Type=simple
User=mattermost
Group=mattermost
WorkingDirectory=/opt/mattermost
ExecStart=/opt/mattermost/bin/mattermost
Restart=always
LimitNOFILE=49152[Install]</code
WantedBy=multi-user.target
Enable and start the service:
<
Enable the site and restart NGINX:


