Hostwinds Tutorials

Search results for:


Table of Contents


Installing MariaDB
Installing Mattermost

Installing Mattermost on CentOS 7

Tags: CentOS Web Panel 

Installing MariaDB
Installing Mattermost

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. Still, it 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.

Installing MariaDB

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:

wget https://downloads.mariadb.com/MariaDB/mariadb_repo_setup
chmod +x mariadb_repo_setup
./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

mysql
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:

[mysql]
user=root
host=localhost
password='YourRootMySQLPassword'
socket=/var/lib/mysql/mysql.sock

Installing Mattermost

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 the time of writing and will be used.

Download the tarball

wget https://releases.mattermost.com/5.24.2/mattermost-5.24.2-linux-amd64.tar.gz
tar -zxvf mattermost*.gz
mv mattermost /opt
mkdir /opt/mattermost/data

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;
> quit;

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.

nano /opt/mattermost/config/config.json

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.
"DataSource": "mmuser:YourMatterMostDBPassword
@tcp(localhost:3306)/mattermost?charset=utf8mb4……

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 actually to exit.

Step 5: Start Mattermost

To run Mattermost as the mattermost user:

cd /opt/mattermost
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://: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)

nano /etc/systemd/system/mattermost.service

and paste in (right-click in PuTTY)

[Unit]
Description=Mattermost
After=syslog.target network.target mysqld.service
[Service]
Type=notify
WorkingDirectory=/opt/mattermost
User=mattermost
ExecStart=/opt/mattermost/bin/mattermost
PIDFile=/var/spool/mattermost/pid/master.pid
TimeoutStartSec=3600
LimitNOFILE=49152
[Install]
WantedBy=multi-user.target

Then ctrl-x, y, and enter.

chmod 664 /etc/systemd/system/mattermost.service
systemctl daemon-reload
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://\: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.

Written by Evan Winter  /  July 3, 2020