How to Install Mattermost with PostgreSQL and Nginx on Ubuntu 16.04

  • by
  • 8 Months ago
  • 0

A tutorial on how to install Mattermost with PostgreSQL and Nginx on Ubuntu 16.04. Mattermost is an open source messaging system written in the programming languages Golang and React. It’s a slack alternative, we can build our own messaging service like slack or hipchat with it. Mattermost brings your team communication to a single place and makes it accessible anywhere. You can access it from your desktop, Android device, and iPhone.


How to Install Mattermost with PostgreSQL and Nginx on Ubuntu 16.04

Step 1 – Install and Configure the PostgreSQL Database

Connect to your server by SSH or login on the terminal and update the Ubuntu repository.

ssh root@
sudo apt-get update

As the root user, install PostgreSQL with this apt command.

sudo apt-get install postgresql postgresql-contrib

When the installation finished, login to the postgres user and type in the command ‘psql‘ to login to the postgresql shell.

su - postgres

Change the postgres user password with the command below:

\password postgres
Enter new password:

Next, we have to configure a new database and user for the Mattermost installation. I will create a new database named ‘mattermostdb‘ and user ‘matteruser‘ with password ‘matterpassword‘. Please chose a secure password for your installation.

Create the new database and user with PostgreSQL query below:

CREATE DATABASE mattermostdb;
CREATE USER matteruser WITH PASSWORD 'matterpassword';

Grant ‘matteruser‘ privileges to the database ‘mattermostdb‘ and exit.

GRANT ALL PRIVILEGES ON DATABASE mattermostdb TO matteruser;

Install Mattermost with PostgreSQL and Nginx on Ubuntu 16.04

Step 2 – Install and Configure Mattermost

Create new ‘matter‘ user and password.

useradd -m -s /bin/bash matter
passwd matter

‘matter’ user created, now login to the user and download the latest Mattermost version with wget.

su - matter

Extract the Mattermost file and you will see new directory ‘mattermost’, enter that directory with the cd command.

tar -xzvf mattermost-3.4.0-linux-amd64.tar.gz
cd mattermost/

Next, create a new ‘data’ directory for storing the user files, then edit the mattermost config file ‘config/config.json‘ with vim.

mkdir data/
vim config/config.json

We will run mattermost behind a Nginx reverse proxy, so it’s better to configure Mattermost to listen on the local IP address. In the ‘ServiceSettings‘ block, add the localhost IP address to the configuration on line 4.

"ListenAddress": "",

Now go to the ‘SqlSettings‘ on line 48. Change the ‘DriverName‘ and ‘DataSource‘ configuration to use the PostgreSQL database with the configuration below:

"DriverName": "postgres",
"DataSource": "postgres://matteruser:matterpassword@",


Pages: 1 2

  • facebook
  • googleplus
  • twitter
  • linkedin
  • linkedin