In the present scenario of Lockdowns and work from home, Companies are investing heavily in online tools. But let's look at the opensource Toolkits that can aid in working from home maybe even better than the paid counterparts.
As we all know Slack being the new best choice for startups and enterprises alike for in company and in team communications. Mattermost is an opensource equivalent with a lesser attractive UI but the same functionalities.
This can either be done on the cloud(such as AWS)or on-premise. The hardware requirements are so low that an EC2 t2.micro can handle around 100 users. If on cloud configure port 80,443 to accept all inbound requests and 22 for your configuration SSH.
Step 1- Upgrade and Update the system
sudo apt update sudo apt -y upgrade sudo apt -y install wget curl vim
It is recommended to reboot after an upgrade
The Next Step is to set a proper Domain name configured
sudo hostnamectl set-hostname chat.example.com --static
Step 2- install the DB
Mattermost supports SQL and Postgress. For the Purpose of the tutorial, let's go ahead with Postgres for reliability and scale.
sudo apt -y install postgresql postgresql-contrib
Since Postgres automatically starts up after an install.Login with Postgres account
sudo --login --user postgres
Start the PostgreSQL interactive terminal and create the Mattermost database/user ‘ mmuser ’ grant necessary rights and exit Postgres account.
psql CREATE DATABASE mattermost; CREATE USER mmuser WITH PASSWORD 'StrongDBPassWord'; GRANT ALL PRIVILEGES ON DATABASE mattermost to mmuser; \q exit
Step 3: Create Mattermost user and group
sudo useradd --system --user-group mattermost
This creates a system user .
Step 4: Download and install Mattermost
With the database server configured, you can now download and install Mattermost. First, visit the Mattermost downloads page to get the latest release.
Assuming the Latest release is 5.22.1
if the Version changes replace x.x.x with the corresponding version and use the link
Now extract the downloaded package
tar xvf mattermost-5.22.1-linux-amd64.tar.gz
Move the extracted file to the /opt directory.
sudo mv mattermost /opt
Next step is to create a directory to store user files
sudo mkdir /opt/mattermost/data
Set correct ownership and permissions
sudo chown -R mattermost:mattermost /opt/mattermost sudo chmod -R g+w /opt/mattermost
Step 5: Configuring the Mattermost server
The config file of Mattermost server is accessible at /opt/mattermost/config/config.json
sudo nano /opt/mattermost/config/config.json
Configure PostgreSQL database settings to look like below under “ SqlSettings “: section.
"DriverName": "postgres", "DataSource": "postgres://mmuser:StrongDBPassWord@localhost:5432/mattermost?sslmode=disable&connect\_timeout=10",
“Service Settings”: “” Section Alter the corresponding values This assumes that you are going to use LetsEncrypt for SSL
"ListenAddress":":443" "ConnectionSecurity":"TLS" "UseLetsEncrypt":true "Forward80To443":true
enabling Lets Encrypt alternate to enable this you can use your self signed certificate by entering appropriate data in fields
HTTP to Https redirect
Enabling Mattermost to bind to lower ports
sudo setcap cap\_net\_bind\_service=+ep /opt/mattermost/bin/platform
Step 6: Configure Systemd Service
Create Mattermost Systemd service unit.
$ sudo vim /etc/systemd/system/mattermost.service
Populate the below data into the file.
[Unit] Description=Mattermost After=network.target After=postgresql.service Requires=postgresql.service [Service] Type=notify ExecStart=/opt/mattermost/bin/platform TimeoutStartSec=3600 Restart=always RestartSec=10 WorkingDirectory=/opt/mattermost User=mattermost Group=mattermost LimitNOFILE=49152 [Install] WantedBy=multi-user.target
Make systemd load the new unit.
sudo systemctl daemon-reload
Start and Enable Mattermost Service
sudo systemctl start mattermost.service sudo systemctl enable mattermost.service
Check service status to make sure it is running.
systemctl status mattermost.service
Verify that Mattermost is running by calling the link on a browser assuming that you have already pointed the DNS.
would return an HTML returned by the server.
Note that the initial signup user would be the default system admin
Access System Console by clicking the go-to system console
Further configurations can be done reading through the Config Document .
You are all set to start utilizing the self-hosted Mattermost server.