Mattermost is an open-source, self-hosted collaboration platform designed for secure team communication. If you’re looking to set it up, you can follow this guide to install Mattermost on Ubuntu 24.04 for a seamless and secure deployment.
Prerequisites
- A fresh Ubuntu 24.04 server.
- Root or sudo privileges.
- Domain name pointing to your server
Step 1: Update System Packages
sudo apt update
Step 2: Install and Configure PostgreSQL
Install PostgreSQL and enable it to start on boot:
sudo apt install postgresql postgresql-contrib -y
sudo systemctl enable postgresql
sudo systemctl start postgresql
Create Mattermost Database and User
Switch to the PostgreSQL user:
su - postgres
Create a new PostgreSQL user and database:
createuser mattermostuser
psql
ALTER USER mattermostuser WITH ENCRYPTED password 'xdghjasgduyhadhfIT';
CREATE DATABASE mattermost OWNER mattermostuser;
GRANT ALL PRIVILEGES ON DATABASE mattermost TO mattermostuser;
\q
exit
Step 3: Download and Install Mattermost
Create a system user for Mattermost:
sudo useradd --system --user-group mattermost
Download and extract Mattermost:
wget https://releases.mattermost.com/6.4.0/mattermost-6.4.0-linux-amd64.tar.gz
tar xvf mattermost-6.4.0-linux-amd64.tar.gz
sudo mv mattermost /opt/
Create data directory and set permissions:
sudo mkdir -p /opt/mattermost/data
sudo chown -R mattermost:mattermost /opt/mattermost
sudo chmod -R g+w /opt/mattermost
Step 4: Configure Mattermost
Edit the Mattermost configuration file:
sudo vim /opt/mattermost/config/config.json
Locate the following fields and update:
"DriverName": "postgres",
"DataSource": "postgres://mattermostuser:<mattermostuser-password>@<host-name-or-IP>:5432/mattermost?sslmode=disable&connect_timeout=10"
replacing <mattermostuser-password> and <host-name-or-IP> with the appropriate values.
Step 5: Create a Systemd Service for Mattermost
Create the systemd service file:
sudo vim /etc/systemd/system/mattermost.service
Paste the following:
[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=postgresql.service
Reload the systemd manager and start Mattermost. Also check the status:
sudo systemctl daemon-reload
sudo systemctl start mattermost
sudo systemctl enable mattermost
sudo systemctl status mattermost
Step 7: Set Up Nginx Reverse Proxy
Install Nginx:
sudo apt install -y nginx
Create a new configuration for mattermost domain:
sudo vim /etc/nginx/sites-enabled/mattermost.conf
Paste the following:
server {
listen 80;
server_name training3.codeinall.com;
error_log /var/log/nginx/mattermost.error;
access_log /var/log/nginx/mattermost.access;
location / {
proxy_pass http://localhost:8065;
}
}
Restart the Nginx:
sudo systemctl restart nginx
Final Step: Access Mattermost
Open your browser and visit: http://training3.codeinall.com
You should see the Mattermost setup page. Create your admin account and configure your team to start using Mattermost.
Conclusion
Successfully installed Mattermost on Ubuntu 24.04. This setup is ideal for teams looking to self-host a secure, customizable messaging platform.
If you’re looking to simplify collaboration and communication by deploying Mattermost, our team can help. From installation to optimization, we ensure a smooth setup tailored to your business needs.
At Skynats, we specialize in DevOps support services and comprehensive server management services to help businesses set up, monitor, and maintain their infrastructure with ease.
Need assistance with Mattermost installation or server management? Contact Skynats today for professional support!