Mattermost

Mattermost is an open-source, self-hosted online chat service written in Go and JavaScript.


Note

For this guide you should be familiar with the basic concepts of

Prerequisites

You’ll need your MySQL credentials. Get them with my_print_defaults:

[isabell@stardust ~]$ my_print_defaults client
--default-character-set=utf8mb4
--user=isabell
--password=MySuperSecretPassword
[isabell@stardust ~]$

Your URL needs to be setup:

[isabell@stardust ~]$ uberspace web domain list
isabell.uber.space
[isabell@stardust ~]$

Installation

Download the most recent Linux TAR archive from the Mattermost website:

[isabell@stardust ~]$ wget https://releases.mattermost.com/5.18.0/mattermost-5.18.0-linux-amd64.tar.gz
--2019-12-23 13:27:01--  https://releases.mattermost.com/5.18.0/mattermost-5.18.0-linux-amd64.tar.gz
Resolving releases.mattermost.com (releases.mattermost.com)... 99.86.88.55, 99.86.88.121, 99.86.88.31, ...
Connecting to releases.mattermost.com (releases.mattermost.com)|99.86.88.55|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 155306557 (148M) [application/x-gzip]
Saving to: ‘mattermost-5.18.0-linux-amd64.tar.gz’

100%[====================================================================>] 155,306,557 22.5MB/s   in 6.6s

2019-12-23 13:27:08 (22.6 MB/s) - ‘mattermost-5.18.0-linux-amd64.tar.gz’ saved [155306557/155306557]

[isabell@stardust ~]$

Extract the archive:

[isabell@stardust ~]$ tar xfv mattermost-5.18.0-linux-amd64.tar.gz
[…]
mattermost/prepackaged_plugins/mattermost-plugin-custom-attributes-v1.0.2.tar.gz
mattermost/prepackaged_plugins/mattermost-plugin-zoom-v1.1.2.tar.gz
[isabell@stardust ~]$

Configuration

Set up a Database

Run the following code to create the database <username>_mattermost in MySQL:

[isabell@stardust ~]$ mysql -e "CREATE DATABASE ${USER}_mattermost COLLATE utf8mb4_unicode_ci;"
[isabell@stardust ~]$

Change the configuration

You need to set up your URL, and MySQL settings in ~/mattermost/config/config.json.

First, set your site URL:

"SiteURL": "https://isabell.uber.space"

Then find the SqlSettings block and replace mmuser with your username, mostest with your MySQL password and mattermost_test with the name of the database you created earlier:

   "SqlSettings": {
     "DriverName": "mysql",
     "DataSource": "isabell:MySuperSecretPassword@tcp(localhost:3306)/isabell_mattermost?charset=utf8mb4,utf8\u0026readTimeout=30s\u0026writeTimeout=30s",
     "DataSourceReplicas": [],
     "DataSourceSearchReplicas": [],
     "MaxIdleConns": 20,
     "ConnMaxLifetimeMilliseconds": 3600000,
     "MaxOpenConns": 300,
     "Trace": false,
     "AtRestEncryptKey": "",
     "QueryTimeout": 30
   },

To configure plugins you have to change the plugin path under PluginSettings:

     "Directory": "/home/isabell/mattermost/plugins",
     "ClientDirectory": "/home/isabell/mattermost/client/plugins",

Additionally, the file storage settings need to be adjusted. Find the FileSettings section and replace the Directory line:

   "FileSettings": {
     "EnableFileAttachments": true,
     "EnableMobileUpload": true,
     "EnableMobileDownload": true,
     "MaxFileSize": 52428800,
     "DriverName": "local",
     "Directory": "/home/isabell/mattermost/data/",
     "EnablePublicLink": false,
     "PublicLinkSalt": "",
     "InitialFont": "nunito-bold.ttf",
     "AmazonS3AccessKeyId": "",
     "AmazonS3SecretAccessKey": "",
     "AmazonS3Bucket": "",
     "AmazonS3PathPrefix": "",
     "AmazonS3Region": "",
     "AmazonS3Endpoint": "s3.amazonaws.com",
     "AmazonS3SSL": true,
     "AmazonS3SignV2": false,
     "AmazonS3SSE": false,
     "AmazonS3Trace": false
   },

Configure web server

Note

Mattermost is running on port 8065.

To make the application accessible from the outside, configure a web backend:

[isabell@stardust ~]$ uberspace web backend set / --http --port <port>
Set backend for / to port <port>; please make sure something is listening!
You can always check the status of your backend using "uberspace web backend list".
[isabell@stardust ~]$

Setup daemon

Create ~/etc/services.d/mattermost.ini with the following content:

[program:mattermost]
command=%(ENV_HOME)s/mattermost/bin/mattermost
autorestart=true

After creating the configuration, tell supervisord to refresh its configuration and start the service:

[isabell@stardust ~]$ supervisorctl reread
SERVICE: available
[isabell@stardust ~]$ supervisorctl update
SERVICE: added process group
[isabell@stardust ~]$ supervisorctl status
SERVICE                            RUNNING   pid 26020, uptime 0:03:14
[isabell@stardust ~]$

If it’s not in state RUNNING, check your configuration.

Setup a user

You can now point your browser to your URL and setup a user.

Further customisation

To further customise your configuration, you can open the system console in your browser and adapt any settings to your wishes. Setting the SMTP server is a good idea.

Updates

Stop your service, backup your /home/isabell/mattermost/client/plugins, /home/isabell/mattermost/config, /home/isabell/mattermost/data, /home/isabell/mattermost/logs and /home/isabell/mattermost/plugins directory and rename/delete your /home/isabell/mattermost directory. Proceed with the installation steps and restore the client/plugins, config, data, logs and plugins directories. Then you can start your service again.


Tested with Mattermost 5.18.0 and Uberspace 7.3.10.0

Written by: Nico Graf <hallo@uberspace.de>