Mattermost is a popular chat and collaboration tool, similar to Slack or Discord, but hosted on a server you control. Installing Mattermost on a Hostwinds Linux VPS or Dedicated server running CentOS 7 is a fairly straightforward process but does require extensive use of the command line for both Linux and MySQL. Start by connecting to your Linux VPS or Dedicated server over SSH.
The default version of MariaDB in CentOS 7 is equivalent to MySQL 5.5, and Mattermost requires 5.6 or higher. To install the latest MariaDB, we’ll need to pull from the MariaDB site instead of the normal CentOS 7 repositories.
Step 1: Download and execute the ‘mariadb repo setup’ script from mariadb.org:
chmod +x mariadb_repo_setup
Step 2: Install and start MariaDB
yum -y install mysqltuner mariadb-server mariadb expect systemctl enable mariadb systemctl start mariadb
Step 3: Set the root password for MariaDB
> ALTER USER 'root'@'localhost' IDENTIFIED BY 'ThisIsAPassword'; > FLUSH PRIVILEGES; > quit;
And you’ll want to save this passsword into /root/.my.cnf for easier mysql command line access:
Step 1: Download Mattermost and extract it
You can find the latest Linux Server download for Mattermost on https://mattermost.com/download/ — 5.24.2 is the most recent at time of writing and will be used.
Download the tarball
tar -zxvf mattermost*.gz
move it to /opt
mv mattermost /opt
and add a subdirectory for the uploaded/embedded media like pictures, video, etc.
Step 2: Add the mattermost database
mysql -u root
> CREATE DATABASE mattermost;
> CREATE USER 'mmuser'@'localhost' IDENTIFIED BY "YourMatterMostDBPassword";
> GRANT ALL PRIVILEGES on mattermost.* TO 'mmuser'@'localhost';
> FLUSH PRIVILEGES;
Step 3: Add a user for Mattermost to run as
useradd --system --user-group mattermost
chown -R mattermost:mattermost /opt/mattermost
chmod -R g+w /opt/mattermost
Step 4: Edit the configuration file to match the database settings above.
The “SiteURL” value near the top should be changed to the hostname of your VPS or a domain pointing to it, e.g. “SiteURL”: “http://hwsrv-12345.hostwindsdns.com”
The “DataSource” line (much further down in the file, use ctrl-w in nano to search) needs to be edited to have the mmuser database password set in step 2, and point to the right database name.
Note: the database name is set between the / and ? above, the default is mattermost_test but the database created in step 2 is just ‘mattermost’ so remove the _test in the config line
ctrl-x to exit nano, y to say yes to saving, then enter to actually exit.
Step 5: Start Mattermost
To run Mattermost as the mattermost user:
sudo -u mattermost ./bin/mattermost
It will take several seconds to start up the first time, as it populates the database, but you should be able to load http://<hostname>:8065 in a browser to make sure it worked. From there, you can create your administrator account and start setting up channels, groups, etc.
Step 6: Turn Mattermost into a service that runs when the server starts
(ctrl-c to exit the running mattermost and return to the root command line)
and paste in (right click in PuTTY)
After=syslog.target network.target mysqld.service
Then ctrl-x, y, and enter.
chmod 664 /etc/systemd/system/mattermost.service
systemctl enable mattermost
systemctl start mattermost
Assuming no errors come out of the systemctl start mattermost, you can (re) load the Mattermost webpage on your server at http://<hostname>:8065
On the Mattermost webpage, you’ll create the first account and then you can jump right into chatting by creating a team, or go to the System Console to change more options in Mattermost.
There are Help links on any Mattermost page that link to documentation, and please stop by our LiveChat if you have any questions.
- Free SSL Certificate from LetsEncrypt
- Web Browser (Ubuntu VPS)
- How to Run Public Deno Server (Linux Cloud VPS)
- Application Cannot Connect to Database
- How to Install Ghost CMS (Ubuntu 16.04 / 18.04 / 20.04)
- How to Install MySQL (CentOS 7)
- Installing and using cockpit-docker (Linux VPS)
- Reinstall Operating System From Cloud Portal
- Custom Nameservers Using Create Private Nameservers
- How to Configure Custom Nameservers in WHM
- Setup cPanel and WHM