Introduction
Mattermost is an open-source messaging platform designed for team collaboration. In this guide, we will walk you through the installation of Mattermost on a Debian 12 server.
Prerequisites
- A server running Debian 12.
- Root access or a user with
sudo
privileges. - Basic knowledge of the command line.
Step 1: Update the System
Ensure that your system is up to date. Run the following commands:
sudo apt update && sudo apt upgrade -y
Step 2: Install Required Dependencies
Install the necessary packages:
sudo apt install -y wget curl vim
Step 3: Install PostgreSQL Database
Mattermost requires a database to function. We will use PostgreSQL for this purpose:
sudo apt install -y postgresql postgresql-contrib
After installation, start the PostgreSQL service:
sudo systemctl start postgresql
sudo systemctl enable postgresql
Log in to the PostgreSQL prompt:
sudo -u postgres psql
Create a new database and user for Mattermost:
CREATE DATABASE mattermost_db;
CREATE USER mattermost_user WITH PASSWORD 'your_password';
GRANT ALL PRIVILEGES ON DATABASE mattermost_db TO mattermost_user;
\q
Make sure to replace your_password
with a strong and secure password.
Step 4: Install Mattermost
Download the latest version of Mattermost:
wget https://releases.mattermost.com/x.x.x/mattermost-x.x.x-linux-amd64.tar.gz
Replace x.x.x
with the latest version number from the Mattermost download page.
Extract the downloaded file:
tar -xvzf mattermost-x.x.x-linux-amd64.tar.gz
Move the extracted files to the appropriate directory:
sudo mv mattermost /opt/mattermost
Create a data directory for Mattermost:
sudo mkdir /opt/mattermost/data
Step 5: Configure Mattermost
Edit the Mattermost configuration file:
sudo vim /opt/mattermost/config/config.json
Locate the following section and update it:
"DriverName": "postgres",
"DataSource": "mattermost_user:your_password@tcp(localhost:5432)/mattermost_db?sslmode=disable",
Make sure to replace your_password
with the password you set for the PostgreSQL user earlier.
Step 6: Set Permissions
Set the correct permissions for the Mattermost directory:
sudo chown -R www-data:www-data /opt/mattermost/*
Step 7: Start Mattermost
Start the Mattermost server:
sudo /opt/mattermost/bin/mattermost
Step 8: Access Mattermost Web Interface
Open a web browser and navigate to http://your_server_ip:8065
. You should see the Mattermost setup page. Follow the prompts to configure your Mattermost instance.
Step 9: Enable Mattermost to Start on Boot (Optional)
If you want Mattermost to start automatically on system boot, create a systemd service file:
sudo vim /etc/systemd/system/mattermost.service
Paste the following content into the file:
[Unit]
Description=Mattermost
After=network.target
[Service]
Type=simple
User=www-data
Group=www-data
ExecStart=/opt/mattermost/bin/mattermost
WorkingDirectory=/opt/mattermost
Restart=on-failure
[Install]
WantedBy=multi-user.target
Save and exit the editor, then enable and start the service:
sudo systemctl enable mattermost
sudo systemctl start mattermost
Conclusion
You have successfully installed Mattermost on Debian 12. You can now use the Mattermost messaging platform for team collaboration.