UbuntuUbuntu Based

How To Install Mattermost on Ubuntu 24.04 LTS

Install Mattermost on Ubuntu 24.04

Mattermost is a powerful, open-source team collaboration platform that provides secure messaging, file sharing, and project management capabilities. As organizations increasingly rely on remote work and digital communication, tools like Mattermost have become essential for maintaining productivity and fostering teamwork. Ubuntu 24.04, the latest long-term support release of the popular Linux distribution, offers a stable and secure environment for hosting Mattermost. In this comprehensive guide, we’ll walk you through the process of installing Mattermost on Ubuntu 24.04, ensuring you have a robust and efficient communication hub for your team.

Prerequisites

Before we begin the installation process, let’s ensure you have everything needed to successfully set up Mattermost on your Ubuntu 24.04 server:

  • A server running Ubuntu 24.04 LTS with at least 2GB of RAM and 10GB of free disk space
  • Root or sudo access to the server
  • A domain name pointed to your server’s IP address (for secure HTTPS access)
  • Basic familiarity with the Linux command line

It’s crucial to have these prerequisites in place to ensure a smooth installation process. If you’re unsure about any of these requirements, take the time to address them before proceeding.

Preparing the Ubuntu 24.04 Server

The first step in our Mattermost installation journey is to prepare the Ubuntu 24.04 server. This involves updating the system, installing necessary dependencies, and configuring firewall settings.

Updating the System

Start by updating your system to ensure you have the latest security patches and software versions:

sudo apt update
sudo apt upgrade -y

Installing Necessary Dependencies

Next, install the required software packages:

sudo apt install -y wget curl gnupg2 software-properties-common apt-transport-https ca-certificates

Configuring Firewall Settings

If you’re using UFW (Uncomplicated Firewall), allow incoming connections on ports 80, 443, and 8065:

sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw allow 8065/tcp
sudo ufw reload

These ports are essential for web traffic (80 and 443) and Mattermost’s default port (8065).

Installing and Configuring PostgreSQL

Mattermost requires a database to store its data. While it supports both MySQL and PostgreSQL, we’ll use PostgreSQL for this guide due to its robustness and performance benefits.

Installing PostgreSQL

Install PostgreSQL using the following commands:

sudo apt install -y postgresql postgresql-contrib

Creating a Mattermost Database

Now, let’s create a database for Mattermost:

sudo -u postgres psql

Once in the PostgreSQL shell, run these commands:

CREATE DATABASE mattermost;
CREATE USER mmuser WITH PASSWORD 'your-password-here';
GRANT ALL PRIVILEGES ON DATABASE mattermost TO mmuser;
\q

Remember to replace ‘your-password-here’ with a strong, unique password.

Setting up a Database User

We’ve already created the database user in the previous step. Ensure you keep the username (mmuser) and password secure, as you’ll need them when configuring Mattermost.

Installing and Configuring Nginx

Nginx will serve as a reverse proxy for Mattermost, handling incoming web traffic and providing SSL/TLS encryption.

Installing Nginx

Install Nginx with this command:

sudo apt install -y nginx

Configuring Nginx for Mattermost

Create a new Nginx configuration file for Mattermost:

sudo nano /etc/nginx/sites-available/mattermost

Add the following configuration, replacing ‘your-domain.com’ with your actual domain:

upstream backend {
   server localhost:8065;
   keepalive 32;
}

server {
   listen 80;
   server_name your-domain.com;

   location ~ /api/v[0-9]+/(users/)?websocket$ {
       proxy_set_header Upgrade $http_upgrade;
       proxy_set_header Connection "upgrade";
       client_max_body_size 50M;
       proxy_set_header Host $http_host;
       proxy_set_header X-Real-IP $remote_addr;
       proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
       proxy_set_header X-Forwarded-Proto $scheme;
       proxy_set_header X-Frame-Options SAMEORIGIN;
       proxy_buffers 256 16k;
       proxy_buffer_size 16k;
       proxy_read_timeout 600s;
       proxy_pass http://backend;
   }

   location / {
       client_max_body_size 50M;
       proxy_set_header Connection "";
       proxy_set_header Host $http_host;
       proxy_set_header X-Real-IP $remote_addr;
       proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
       proxy_set_header X-Forwarded-Proto $scheme;
       proxy_set_header X-Frame-Options SAMEORIGIN;
       proxy_buffers 256 16k;
       proxy_buffer_size 16k;
       proxy_read_timeout 600s;
       proxy_pass http://backend;
   }
}

Setting up SSL/TLS Certificates

For secure HTTPS access, install Certbot to obtain and manage SSL/TLS certificates:

sudo apt install -y certbot python3-certbot-nginx
sudo certbot --nginx -d your-domain.com

Follow the prompts to complete the certificate installation and Nginx configuration.

Downloading and Installing Mattermost

Now that we have our database and web server set up, let’s proceed with installing Mattermost itself.

Downloading the Latest Mattermost Version

Download the latest version of Mattermost:

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

Note: Check the Mattermost website for the most recent version number and update the URL accordingly.

Extracting and Moving Mattermost Files

Extract the downloaded archive and move it to the appropriate location:

tar -xvzf mattermost-*.tar.gz
sudo mv mattermost /opt/

Setting up Mattermost User and Permissions

Create a dedicated user for Mattermost and set the correct permissions:

sudo useradd --system --user-group mattermost
sudo chown -R mattermost:mattermost /opt/mattermost
sudo chmod -R g+w /opt/mattermost

Configuring Mattermost

With Mattermost installed, we now need to configure it to work with our PostgreSQL database and other settings.

Editing the Configuration File

Copy the default configuration file and edit it:

sudo cp /opt/mattermost/config/config.json /opt/mattermost/config/config.json.bak
sudo nano /opt/mattermost/config/config.json

Setting up Database Connection

Locate the “SqlSettings” section and update it with your PostgreSQL details:

"SqlSettings": {
    "DriverName": "postgres",
    "DataSource": "postgres://mmuser:your-password-here@localhost:5432/mattermost?sslmode=disable&connect_timeout=10"
}

Configuring File Storage

In the same configuration file, set up the file storage location:

"FileSettings": {
    "DriverName": "local",
    "Directory": "/opt/mattermost/data/"
}

Setting Up Mattermost as a System Service

To ensure Mattermost starts automatically with your system and can be easily managed, we’ll set it up as a systemd service.

Creating a systemd Service File

Create a new systemd service file:

sudo nano /etc/systemd/system/mattermost.service

Add the following content:

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

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

[Install]
WantedBy=multi-user.target

Enabling and Starting the Mattermost Service

Enable and start the Mattermost service:

sudo systemctl daemon-reload
sudo systemctl enable mattermost
sudo systemctl start mattermost

Verifying the Service Status

Check if Mattermost is running correctly:

sudo systemctl status mattermost

You should see “active (running)” in the output.

Accessing and Initial Setup of Mattermost

With Mattermost installed and running, it’s time to access it and perform the initial setup.

Accessing Mattermost through a Web Browser

Open your web browser and navigate to your domain (https://your-domain.com). You should see the Mattermost setup page.

Install Mattermost on Ubuntu 24.04

Creating the First Admin Account

Follow the on-screen instructions to create your first admin account. This account will have full administrative privileges for your Mattermost instance.

Basic Configuration Steps

After creating your admin account, you’ll be guided through some basic configuration steps, including:

  • Setting up your team
  • Inviting team members
  • Configuring notification preferences
  • Setting up integrations (optional)

Troubleshooting Common Issues

Even with careful installation, you might encounter some issues. Here are solutions to common problems:

Database Connection Problems

If Mattermost can’t connect to the database:

  • Double-check your database credentials in the Mattermost config file
  • Ensure PostgreSQL is running: sudo systemctl status postgresql
  • Verify that the database and user were created correctly in PostgreSQL

Nginx Configuration Errors

If you’re having issues with Nginx:

  • Check Nginx error logs: sudo tail -f /var/log/nginx/error.log
  • Verify your Nginx configuration: sudo nginx -t
  • Ensure Nginx is running: sudo systemctl status nginx

Mattermost Service Not Starting

If the Mattermost service fails to start:

  • Check Mattermost logs: sudo journalctl -u mattermost
  • Verify permissions on Mattermost files and directories
  • Ensure all required dependencies are installed

Optimizing Mattermost Performance

To ensure optimal performance of your Mattermost instance:

Adjusting Server Settings

  • Increase the maximum number of open files: Edit /etc/security/limits.conf
  • Optimize PostgreSQL settings in postgresql.conf based on your server’s resources

Implementing Caching Mechanisms

Consider setting up a caching solution like Redis to improve Mattermost’s performance, especially for larger teams.

Congratulations! You have successfully installed Mattermost. Thanks for using this tutorial for installing Mattermost on Ubuntu 24.04 LTS system. For additional help or useful information, we recommend you check the official Mattermost website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.
Back to top button