selfhosted:mattermost

Mattermost

${shell}:~$ wget https://releases.mattermost.com/3.8.2/mattermost-3.8.2-linux-amd64.tar.gz
${shell}:~$ sudo tar -xvzf mattermost*.gz
${shell}:~$ sudo mv mattermost /opt/mattermost
${shell}:~$ sudo mkdir /opt/mattermost/data
${shell}:~$ sudo chown -R mattermost:mattermost /opt/mattermost
${shell}:~$ sudo chmod -R g+w /opt/mattermost

See Common Linux Commands to create a mattermost user

Choose msyql or psql.

Mysql:

See MYSQL to:

  1. install
  2. create user
  3. create databases
  4. grant user privileges to the databases
  5. flush privileges
    $ sudo nano /opt/mattermost/config/config.json
      < /opt/mattermost/config/config.json >
        "SqlSettings": {
          "DriverName": "mysql",
          "DataSource:": "${user}:${password}@tcp(${host}:3306)/mattermost?charset=utf8mb4,utf8&readTimeout=20s&writeTimeout=20s"
        },

Psql:

See PostgreSQL to

  1. install
  2. create user
  3. create databases
  4. grant user privileges to the databases
  $ sudo nano /opt/mattermost/config/config.json
    < /opt/mattermost/config/config.json >
      "SqlSettings": {
        "DriverName": "postgres",
        "DataSource:": "postgres://${user}:${password}@${host}:5432/mm?sslmode=disable&connect_timeout=10"
      },
  # if server is not local
    $ sudo nano /etc/postgresql/9.3/main/pg_hba.conf
      < /etc/postgresql/9.3/main/pg_hba.conf >
        host all all ${servername}/32 md5
  # reload postgres
  sudo /etc/init.d/postgresql restart
  postgres=# \l
  #                                  List of databases
  #   Name    |  Owner   | Encoding |   Collate   |    Ctype    |   Access privileges   
  #  -----------+----------+----------+-------------+-------------+-----------------------
  #  mm        | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =Tc/postgres         +
  #           |          |          |             |             | postgres=CTc/postgres+
  #           |          |          |             |             | mmsuser=CTc/postgres
  #  postgres  | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
  #  template0 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
  #           |          |          |             |             | postgres=CTc/postgres
  #  template1 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
  #           |          |          |             |             | postgres=CTc/postgres
  #  (4 rows)
  postgres=# \c mm
  postgres=# \dt
  postgres=# select * from users;
  # id             |   createat    |   updateat    | deleteat | username  |                           password                           | authdata | authservice |           email           | emailverified | nickname | firstname | lastname | position |          roles           | allowmarketing | props |                                                                                                                      notifyprops                                                                                                                      | lastpasswordupdate | lastpictureupdate | failedattempts | locale | mfaactive | mfasecret |                                  timezone                                  
  ----------------------------+---------------+---------------+----------+-----------+--------------------------------------------------------------+----------+-------------+---------------------------+---------------+----------+-----------+----------+----------+--------------------------+----------------+-------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------+-------------------+----------------+--------+-----------+-----------+----------------------------------------------------------------------------
  # xxxxxxxxxxxxxxxx | 1594596804655 | 1594597305231 |        0 | mmmadmin  | xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |          |             | xxxxxx@mail.com | f             |          |           |          |          | system_user system_admin | f              | {}    | {"channel":"true","comments":"never","desktop":"mention","desktop_sound":"true","email":"true","first_name":"false","mention_keys":"","push":"mention","push_status":"away"}                                                                          |      1594596804655 |                 0 |              0 | en     | f         |           | {"automaticTimezone":"","manualTimezone":"","useAutomaticTimezone":"true"}

(4 rows)

email:
  $ sudo nano /opt/mattermost/config/config.json
    < /opt/mattermost/config/config.json >
      "EmailSettings": {
        "EnableSignUpWithEmail": true,
        "EnableSignInWithEmail": true,
        "EnableSignInWithUsername": true,
        "SendEmailNotifications": true,
        "RequireEmailVerification": false,
        "FeedbackName": "Mattermost Notification",
        "FeedbackEmail": "${email}",
        "FeedbackOrganization": "",
        "SMTPUsername": "${email}",
        "SMTPPassword": "${password}",
        "SMTPServer": "${server}",
        "SMTPPort": "${port}",
        "ConnectionSecurity": "STARTTLS",
        "InviteSalt": "fihisqi8aexeou8qdzbu1xae4yhh445k",
        "PasswordResetSalt": "bjeoqjqof6kuso4964tg9pzfzqcjrrkx",
        "SendPushNotifications": false,
        "PushNotificationServer": "",
        "PushNotificationContents": "generic",
        "EnableEmailBatching": true,
        "EmailBatchingBufferSize": 256,
        "EmailBatchingInterval": 30,
        "SkipServerCertificateVerification": false
      },

sockets:

$ sudo nano /opt/mattermost/config/config.json
  < /opt/mattermost/config/config.json >
    "ServiceSettings": {
      "AllowCorsFrom": "hostname1 hostname1:443 https://hostname1",
    },

services:

See Common Linux Commands to set up an initd service for mattermost

  < /etc/init.d/${servicename} >
    #! /bin/bash
    USER=`id -u ${user}`
    PIDFILE=/var/run/${servicename}.pid
    CMD=/opt/mattermost/bin/platform
    case "$1" in
      start)
      start-stop-daemon --start --user $USER --pidfile $PIDFILE --chuid $USER --startas $CMD
      ;;
      stop)
      start-stop-daemon --stop --user $USER --pidfile $PIDFILE --chuid $USER
      ;;
    esac
    exit 0
  systemctl:
    servicename: mattermost
    description: Mattermost
    after: network.target postgresql.service
    requires: postgresql.service
    type: simple
    execstart: /opt/mattermost/bin/platform
    user: mattermost
    group: mattermost
    restart: always
    restarttime: 10
    workdir: /opt/mattermost
    limit: 49152
commandline:
  # create user
  ./platform user create --email "email1" --password "password1" --username "mmmadmin"
  # convert to admin role
  ./platform roles system_admin xxxxxxxxxxxxxxxxx
  • selfhosted/mattermost.txt
  • Last modified: 2023/07/03 01:43
  • by hli