Install Mattermost on an Ubuntu VPS


In this article, we will show you how to install Mattermost on an Ubuntu 14.04 VPS with PostgreSQL and Nginx. Mattermost is an open-source, on-prem Slack-alternative written in Golang and React. This guide should work on other Linux VPS systems as well but was tested and written for an Ubuntu 14.04 VPS.

Login to your VPS via SSH

ssh user@vps

Update the system and install necessary packages

[user]$ sudo apt-get update && sudo apt-get -y upgrade
[user]$ sudo apt-get install software-properties-common wget

Create a new user

To create a new system user called mmuser run the following commands:

[user]$ sudo adduser --home /opt/mmuser --shell /bin/bash --gecos 'Mattermost application' mmuser
[user]$ sudo install -d -m 755 -o mmuser -g mmuser /opt/mmuser

Install PostgreSQL

To install PostgreSQL on your Ubuntu VPS, just run:

[user]$ sudo apt-get install postgresql postgresql-contrib

After the PostgreSQL installation is complete, log in to the psql shell and create a new mmuser user:

[user]$ sudo -i -u postgres
[postgres]$ psql
postgres=# CREATE DATABASE mmdb;
postgres=# CREATE USER mmuser WITH PASSWORD 'mmuser_password';
postgres=# GRANT ALL PRIVILEGES ON DATABASE mmdb to mmuser;
postgres=# \q
[postgres]$ exit

Install Mattermost

Create a new mattermost directory and change to it:

[user]$ mkdir -p /opt/mmuser/mattermost
[user]$ cd /opt/mmuser/mattermost

Download the latest stable branch of the Mattermost (At the time of the writing of this article, the stable version is 1.1)

[user]$ wget -q -O - | tar -xzf - --strip 1 -C /opt/mmuser/mattermost

Create the storage directory using the following command:

[user]$  mkdir -p /opt/mmuser/mattermost/data

Edit the config/config.json file

[user]$ nano /opt/mmuser/mattermost/config/config.json

and change the database information as follows:

"DriverName": "postgres",
"DataSource": "postgres://mmuser:mmuser_password@",

and enter your SMTP server settings.

Change ownership to mmuser user and group:

[user]$ sudo chown mmuser: -R /opt/mmuser

Test the Mattermost server for the first time by typing:

[user]$ sudo -u mmuser bin/platform

You should see something like below :

[10/16/15 17:40:49] [INFO] Starting Server...
[10/16/15 17:40:49] [INFO] Server is listening on :8065

Hit CTRL-C to stop the server.

Create a systemd service

To create a new systemd service for Mattermost, open your editor of choice

[user]$ sudo nano /etc/init/mattermost.conf

and create a new file with the following content:

description "Mattermost Service"

start on filesystem or runlevel [2345]
stop on runlevel [!2345]

setuid mmuser
setgid mmuser


chdir /opt/mmuser/mattermost
exec bin/platform

You can now start your Mattermost service with:

[user]$ sudo service mattermost start

and check the status with

[user]$ sudo service mattermost status

Install and configure Nginx

Ubuntu 14.04 comes with Nginx version 1.4, to install the latest stable version of Nginx version 1.8, run:

[user]$ sudo add-apt-repository -y ppa:nginx/stable
[user]$ sudo apt-get update
[user]$ sudo apt-get -y install nginx

If you don’t have a CA-signed certificate, you can generate a self-signed certificate with the following commands:

[user]$ sudo mkdir -p /etc/nginx/ssl
[user]$ cd /etc/nginx/ssl
[user]$ sudo openssl genrsa -des3 -passout pass:x -out mattermost.pass.key 2048
[user]$ sudo openssl rsa -passin pass:x -in mattermost.pass.key -out mattermost.key
[user]$ sudo rm mattermost.pass.key
[user]$ sudo openssl req -new -key mattermost.key -out mattermost.csr
[user]$ sudo openssl x509 -req -days 365 -in mattermost.csr -signkey mattermost.key -out mattermost.crt

Create a new Nginx server block

[user]$ sudo nano /etc/nginx/sites-available/your_mattermost_site

with the following content:

server {
    listen      443;
    server_name your_mattermost_site;

    ssl on;
    ssl_certificate     /etc/nginx/ssl/mattermost.crt;
    ssl_certificate_key /etc/nginx/ssl/mattermost.key;
    ssl_session_timeout 5m;

    ssl_ciphers               'AES128+EECDH:AES128+EDH:!aNULL';
    ssl_protocols              TLSv1 TLSv1.1 TLSv1.2;
    ssl_prefer_server_ciphers on;

    access_log  /var/log/nginx/mattermost.access.log;
    error_log   /var/log/nginx/mattermost.error.log;

    location / {
            gzip off;
            proxy_set_header X-Forwarded-Ssl on;
            client_max_body_size 50M;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
            proxy_set_header Host $http_host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_set_header   X-Frame-Options   SAMEORIGIN;
            proxy_pass http://localhost:8065;

server {
    listen      80;
    server_name your_mattermost_site;

    add_header Strict-Transport-Security max-age=2592000;
    rewrite ^ https://$server_name$request_uri? permanent;

Activate the server block by creating a symbolic link :

[user]$ sudo ln -s /etc/nginx/sites-available/your_mattermost_site /etc/nginx/sites-enabled/your_mattermost_site

Test the Nginx configuration and restart Nginx:

[user]$ sudo nginx -t
[user]$ sudo service nginx restart

Final steps

Open http://myour_mattermost_site in your favorite web browser and create a team and user. Administrative access is automatically granted to the first registered user.

That’s it. You have successfully installed Mattermost on your Ubuntu 14.04 VPS. For more information about Mattermost, please refer to the official Mattermost documentation.

If you’d like to learn how to install Mattermost Chat on Ubuntu 20.04, we have a tutorial for that as well.

Of course, you don’t have to do any of this if you use one of our Linux VPS Hosting services, in which case you can simply ask our expert Linux admins to set this up for you. They are available 24×7 and will take care of your request immediately.

PS. If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.

4 thoughts on “Install Mattermost on an Ubuntu VPS”

  1. Hi,

    Thanks for the tutorial!
    I’ve got a problem when running sudo -u mmuser bin/platform, the server answers this :
    bin/platform: 1: bin/platform: ELF: not found
    bin/platform: 1: bin/platform: Aw褩??H??H?H?υ?H??̅?H???o?=?6?t?e??+: not found
    bin/platform: 2: bin/platform: Syntax error: end of file unexpected (expecting “)”)

    Thanks by advance,


    • Please download the latest version using:
      wget -q -O – | tar -xzf – –strip 1 -C /opt/mmuser/mattermost

  2. Hi, how to adapt the code for an install in a subfolder ?
    Thanks, i’m not use to linux and command line and more with linux directory system.

    • If you want a working version of Mattermost, you should be following the exact installation manual, without any path changes.


Leave a Comment

To prove you are human please solve the following *