Mattermost is an open source, self-hosted Slack alternative for team communication. Installing Mattermost on Ubuntu Server is simple and straightforward when you follow the steps in this guide.
Before installing Mattermost, you must update and upgrade the system to ensure that you are working with the latest software packages.
sudo apt-get update && sudo apt-get upgrade -y
Mattermost is built using Go. Therefore, you need to install Go and other dependencies for it to work correctly.
sudo apt-get install curl wget git nano libpq5 libpq-dev postgresql postgresql-contrib build-essential software-properties-common -y
Mattermost uses Nginx as a reverse proxy server. Therefore, installing it is necessary.
sudo apt-get install nginx -y
You can download the latest version of Mattermost from the official website at https://mattermost.com/download/ using the following commands:
cd /opt
sudo wget https://releases.mattermost.com/5.39.1/mattermost-team-5.39.1-linux-amd64.tar.gz
sudo tar -xzvf mattermost-team-5.39.1-linux-amd64.tar.gz
sudo useradd --system --user-group mattermost
sudo chown -R mattermost:mattermost mattermost/
sudo chmod -R g+w mattermost/
Note that you will need to replace 5.39.1
with the latest version of Mattermost available.
You need to create a database and a user for Mattermost to connect to. Run the following commands:
sudo -u postgres psql
CREATE DATABASE mattermost;
CREATE USER mattermost WITH encrypted password 'your-password-here';
GRANT ALL PRIVILEGES ON DATABASE mattermost TO mattermost;
\q
Create a new Nginx configuration file for Mattermost using your favorite text editor:
sudo nano /etc/nginx/sites-available/mattermost
Here is a basic Mattermost Nginx configuration:
upstream backend {
server 127.0.0.1:8065;
}
server {
listen 80;
server_name mattermost.example.com; # Your server's domain name
if ($scheme != "https") {
return 301 https://$server_name$request_uri;
}
access_log /var/log/nginx/mattermost-access.log;
error_log /var/log/nginx/mattermost-error.log;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
client_max_body_size 50M;
proxy_buffering off;
proxy_request_buffering off;
proxy_http_version 1.1;
proxy_pass http://backend;
}
location ~ /api/v[0-9]+/(users/)?websocket$ {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_buffering off;
proxy_request_buffering off;
proxy_http_version 1.1;
proxy_pass http://backend;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
After creating the configuration file, create a symbolic link to the sites-enabled
directory and restart Nginx:
sudo ln -s /etc/nginx/sites-available/mattermost /etc/nginx/sites-enabled/mattermost
sudo service nginx restart
Copy the configuration file template that comes with Mattermost:
sudo cp /opt/mattermost/config/config.json /opt/mattermost/config/config.orig.json
Using your favorite text editor, create a new configuration file with the following content:
sudo nano /opt/mattermost/config/config.json
{
"ServiceSettings": {
"SiteURL": "https://mattermost.example.com", # Your server's domain name
"ListenAddress": ":8065",
"ConnectionSecurity": "TLS",
"TLSCertFile": "/etc/letsencrypt/live/mattermost.example.com/fullchain.pem", # Path to your SSL certificate
"TLSKeyFile": "/etc/letsencrypt/live/mattermost.example.com/privkey.pem", # Path to your SSL key
"UseLetsEncrypt": false,
"LetsEncryptCertificateCacheFile": "./config/letsencrypt.cache",
},
"TeamSettings": {
"SiteName": "Mattermost",
"MaxUsersPerTeam": 50,
"EnableTeamCreation": true
},
"LogSettings": {
"EnableFileLocation": true,
"FileLocation": "/var/log/mattermost/mm.log",
"EnableConsole": false,
"ConsoleLevel": "INFO",
"EnableWebhookDebugging": false,
"EnableDiagnostics": false
},
"SqlSettings": {
"DriverName": "postgres",
"DataSource": "postgres://mattermost:your-password-here@localhost:5432/mattermost?sslmode=disable&connect_timeout=10",
"DataSourceReplicas": [],
"MaxIdleConns": 10,
"ConnMaxLifetimeMilliseconds": 3600000,
"MaxOpenConns": 10,
"Trace": false,
"AtRestEncryptKey": "your-at-rest-encryption-key-here",
"QueryTimeout": 30
}
}
Make sure you change the values according to your server's configuration.
You can now start Mattermost using the following command:
sudo -u mattermost /opt/mattermost/bin/mattermost
To run Mattermost in the background, use the following command:
sudo -u mattermost /opt/mattermost/bin/mattermost & disown
Installing Mattermost on Ubuntu Server Latest is straightforward when you follow the steps in this guide. Once complete, you will have your own independent Slack alternative to communicate with your team.
If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!
Alternatively, for the best virtual desktop, try Shells!