Mattermost is an open source, self-hosted alternative to the Slack SAAS messaging service. In other words, with Mattermost, you can setup a private and dedicated messaging server on your own machine for your team.
Prerequisites
- A newly created Ubuntu 16.04 server instance. Say its IP address is
203.0.113.1
.
- A sudo user.
- The server instance has been updated to the latest stable status using the EPEL YUM repo.
- A domain
mattermost.example.com
that has been configured to point to the 203.0.113.1
server instance. You can learn more details about this in another Vultr tutorial.
- In order to automatically obtain the Let's Encrypt certificate, the server instance's FQDN should have been configured as
mattermost.example.com
.
Use the following commands to update your packages.
sudo apt update
sudo apt upgrade
As required by Mattermost, you need to setup a database to store all the data for Mattermost. For that purpose, we will install MySQL.
Use the following command to install MySQL Server.
sudo apt install mysql-server
It will prompt you to choose a password for the root MySQL account,
Then, login to MySQL as root.
mysql -u root -p
Create the Mattermost user mmuser
.
mysql> create user 'mmuser'@'%' identified by 'mmuser-password';
Note: Change the password mmuser-password
to something more secure.
Create the Mattermost database.
mysql> create database mattermost;
Grant access privileges to the user mmuser
.
mysql> grant all privileges on mattermost.* to 'mmuser'@'%';
Finally, log out of MySQL.
mysql> exit
Download and extract the Mattermost 5.2 archive.
cd
wget https://releases.mattermost.com/5.2.0/mattermost-5.2.0-linux-amd64.tar.gz
tar -zxvf mattermost-5.2.0-linux-amd64.tar.gz
Move all Mattermost files to the /opt
directory, and then create a subdirectory /opt/mattermost/data
to store program data.
sudo mv mattermost /opt
sudo mkdir /opt/mattermost/data
Create a dedicated user mattermost
and a dedicated group mattermost
for running Mattermost.
sudo useradd --system --user-group mattermost
Set the user and group mattermost
as the owner of the Mattermost files.
sudo chown -R mattermost:mattermost /opt/mattermost
Give write permissions to the mattermost
group.
sudo chmod -R g+w /opt/mattermost
Set up the database driver in the file /opt/mattermost/config/config.json
. Open the file.
nano /opt/mattermost/config/config.json
Find these lines.
"SiteURL": "",
"ListenAddress": ":8065",
"DataSource": "mmuser:mostest@tcp(dockerhost:3306)/mattermost_test?charset=utf8mb4,utf8&readTimeout=30s&writeTimeout=30s",
Replace them with the lines below.
"SiteURL": "http://mattermost.example.com",
"ListenAddress": ":80",
"DataSource": "mmuser:<mmuser-password>@tcp(localhost:3306)/mattermost?charset=utf8mb4,utf8&readTimeout=30s&writeTimeout=30s",
Make sure DriverName
is set to mysql
then set DataSource
to the following value, replacing <mmuser-password>
with the appropriate value. Also make sure that the database name is mattermost
instead of mattermost_test
:
Then exit by pressing CTRL+X and then Y to save.
Allow Mattermost to bind to privileged ports, for example, 80
and 443
.
cd /opt/mattermost/bin
sudo setcap cap_net_bind_service=+ep ./platform
sudo setcap cap_net_bind_service=+ep ./mattermost
Create the Mattermost systemd
unit file and open it using nano as root.
nano /etc/systemd/system/mattermost.service
Populate it with the following.
[Unit]
Description=Mattermost
After=syslog.target network.target mysqld.service
[Service]
Type=simple
WorkingDirectory=/opt/mattermost/bin
User=mattermost
ExecStart=/opt/mattermost/bin/platform
PIDFile=/var/spool/mattermost/pid/master.pid
LimitNOFILE=49152
[Install]
WantedBy=multi-user.target
Modify permissions on this systemd
unit file.
sudo chmod 664 /etc/systemd/system/mattermost.service
Start the Mattermost service and make it automatically start on system boot.
sudo systemctl daemon-reload
sudo systemctl start mattermost.service
sudo systemctl enable mattermost.service
Finally, point your favorite web browser to http://mattermost.example.com
or https://mattermost.example.com
, and you will see the Mattermost Sign Up
page.
On the Mattermost Sign Up
page, input an email address
, a username
, and a password
, and then click the Create Account
button to register the first user.
Note: Be aware that the first user you register will also be the system administrator.
On the Team Name
page and the Team URL
page, input a team name
and a URL
for your first team.
You have now successfully setup a Mattermost messaging server which is robust enough to serve a small or mid-sized team in a production environment. Feel free to explore the interface of Mattermost and invite more team members.