Recently I’ve covered two different routes to deploying Mattermost to your network. The first method was via a TurnKey Linux virtual appliance and the second installed a newer version of the platform (which included kanban boards and Playlists) using Docker.
SEE: 40+ open source and Linux terms you need to know (TechRepublic Premium)
This time around, however, we’re going to do a full installation of Mattermost on Ubuntu Server 22.04. For anyone who wants a production-ready instance of Mattermost, this is the route to go. Let’s dive in and get this amazing, open-source collaboration tool up and running.
What you’ll need
The only two things you’ll need to get Mattermost installed in this fashion are a running instance of Ubuntu Server 22.04 (although it will also work on Ubuntu 20.04) and a user with sudo privileges. That’s it, let’s get this tool up and running.
How to install the MySQL database server
The first thing to do is install the necessary database server (Mattermost can be run with either MySQL or PostgreSQL). Log into Ubuntu Server and install MySQL database server with:
sudo apt-get install mysql-server -y
Once the installation completes, secure the database server with:
sudo mysql_secure_installation
Make sure to set a strong password for the admin user and answer y to the remaining questions.
Start and enable the database server with the following commands:
sudo systemctl start mysqld
sudo systemctl enable mysql
How to create the database and user
Log in to the MySQL console with the command:
sudo mysql -u root -p
Create the required database with:
CREATE DATABASE mattermost;
Create the new user with:
CREATE USER 'mmuser'@'localhost' IDENTIFIED BY 'PASSWORD';
Where PASSWORD is a strong/unique password.
Grant the necessary permissions to the new database with:
GRANT ALL PRIVILEGES ON mattermost.* TO 'mmuser'@'localhost';
Flush the privileges and exit the console with:
FLUSH PRIVILEGES;
exit
How to download and extract Mattermost
Download the latest version of Mattermost (make sure to check and see that you’re downloaded the latest release) with the command:
wget wget https://releases.mattermost.com/6.6.0/mattermost-6.6.0-linux-amd64.tar.gz
Unpack the file with:
tar -xvzf mattermost*.gz
Move the newly created directory with the command:
sudo mv mattermost /opt
Create a storage directory with:
sudo mkdir /opt/mattermost/data
How do create a new user and set the proper permissions
Create a new Mattermost user and group with the command:
sudo useradd --system --user-group mattermost
We now need to set the Mattermost directory to be owned by the mattermost user and group with:
sudo chown -R mattermost:mattermost /opt/mattermost
Finally, set the proper permissions with:
sudo chmod -R g+w /opt/mattermost
How to configure the Mattermost server for the database
Open the Mattermost configuration file with:
sudo nano /opt/mattermost/config/config.json
In that file, look for two lines that start with:
"DriverName":
"DataSource":
Those two lines should like exactly like this (substituting PASSWORD for the password you set for the mmuser database user):
"DriverName": "mysql",
"DataSource": "mmuser:PASSWORD@tcp(localhost:3306)/mattermost?charset=utf8mb4,utf8\u0026readTimeout=30s\u0026writeTimeout=30s",
Save and close the file.
How to create a systemd startup file
Time to create a systemd startup file for Mattermost. Create the file with the command:
sudo nano /lib/systemd/system/mattermost.service
Paste the following contents into that file:
[Unit]
Description=Mattermost
After=network.target
After=postgresql.service
BindsTo=postgresql.service
[Service]
Type=notify
ExecStart=/opt/mattermost/bin/mattermost
TimeoutStartSec=3600
KillMode=mixed
Restart=always
RestartSec=10
WorkingDirectory=/opt/mattermost
User=mattermost
Group=mattermost
LimitNOFILE=49152
[Install]
WantedBy=multi-user.target
Reload the systemd daemon with:sudo systemctl daemon-reload
Start and enable the service with:sudo systemctl enable --now mattermost
How to finish up the installation
We can now finish up the installation by logging into the web-based interface at http://SERVER:8065 (Where SERVER is the IP address or domain of the hosting server). You should be greeted by the initial account creation window (Figure A).
Figure A
Fill out the required information and click Create Account. Next, you’ll be prompted to name your organization (Figure B).
Figure B
Click Continue and then, when prompted, confirm the server URL (Figure C) and click Continue.
Figure C
Click Continue and then select how you plan on using Mattermost (Figure D).
Figure D
Make your selection and click Continue. You will then be asked if you want to connect any available third-party tools to your Mattermost instance (Figure E).
Figure E
Click Continue to finish up the installation.
Finally, you’ll be asked to create your first Mattermost channel (Figure F).
Figure F
Type a name for the channel and click Continue. You can then invite members to the instance by copying the invite link and clicking Finish Setup, which will launch your Workspace where you’re ready to get to the business of business (Figure G).
Figure G
Congratulations, you’ve just deployed Mattermost to Ubuntu Server for a full-featured, collaboration platform that will empower your teams to do great things.
Subscribe to TechRepublic’s How To Make Tech Work on YouTube for all the latest tech advice for business pros from Jack Wallen.