<\/span><\/h2>\n\n\n\nLog in to your Debian 11 VPS with SSH as a root user:<\/p>\n\n\n\n
ssh root@IP_Address -p Port_number<\/pre>\n\n\n\nYou can check whether you have the proper Debian version installed on your server with the following command:<\/p>\n\n\n\n
# lsb_release -a<\/pre>\n\n\n\nYou should get this output:<\/p>\n\n\n\n
Distributor ID: Debian\nDescription: Debian GNU\/Linux 11 (bullseye)\nRelease: 11\nCodename: bullseye\n<\/pre>\n\n\n\nOnce you are logged in, run the following command to update all installed packages to the latest available version.<\/p>\n\n\n\n
apt update && apt upgrade<\/pre>\n\n\n\n<\/span>Step 2: Install MariaDB<\/span><\/h2>\n\n\n\nMattermost uses MariaDB\/MySQL as a database backend. The default version available to install is MariaDB 10.5.<\/p>\n\n\n\n
We can install it with the following command:<\/p>\n\n\n\n
apt install mariadb-server<\/pre>\n\n\n\nSecure your MariaDB installation by using the mysql_secure_installation<\/code> script. This script will remove anonymous users, disallow root login remotely, and remove the test database.<\/p>\n\n\n\nmysql_secure_installation<\/pre>\n\n\n\nYou should answer all the questions as shown below:<\/p>\n\n\n\n
Enter current password for root (enter for none): Press [Enter] since no password is set by default\nSet root password? [Y\/n]: N (Optional)\nRemove anonymous users? [Y\/n]: Y\nDisallow root login remotely? [Y\/n]: Y\nRemove test database and access to it? [Y\/n]: Y\nReload privilege tables now? [Y\/n]: Y<\/pre>\n\n\n\n<\/span>Step 3: Create a Mattermost Database<\/span><\/h2>\n\n\n\nOnce MariaDB is secured, log in to MariaDB shell:<\/p>\n\n\n\n
mysql -u root -p<\/pre>\n\n\n\nProvide your MariaDB root password when prompted (if you set one), then create a database and user for Mattermost:<\/p>\n\n\n\n
MariaDB [(none)]> CREATE DATABASE mattermost;\nMariaDB [(none)]> CREATE USER 'mmuser'@'%';\nMariaDB [(none)]> SET PASSWORD FOR 'mmuser'@'%' = PASSWORD('Str0ngPa$$worD');<\/pre>\n\n\n\nMake sure to use a unique password for the database user.<\/p>\n\n\n\n
Next, grant all the privileges to Mattermost database with the following command:<\/p>\n\n\n\n
MariaDB [(none)]> GRANT ALL ON mattermost.* TO 'mmuser'@'%' IDENTIFIED BY 'Str0ngPa$$worD' WITH GRANT OPTION;<\/pre>\n\n\n\nNext, flush the privileges and exit from the MariaDB shell with the following command:<\/p>\n\n\n\n
MariaDB [(none)]> FLUSH PRIVILEGES;\nMariaDB [(none)]> EXIT;<\/pre>\n\n\n\nOnce you have done it, you can proceed to the next step.<\/p>\n\n\n\n
<\/span>Step 4: Download and Install Mattermost Server<\/span><\/h2>\n\n\n\nFirst, create a new user and group that will run our Mattermost server.<\/p>\n\n\n\n
sudo useradd --system --user-group mattermost<\/pre>\n\n\n\nAt the time of writing this article, the latest version of Mattermost is 6.0.2. You can download it from the Mattermost download page using the following command:<\/p>\n\n\n\n
wget wget https:\/\/releases.mattermost.com\/6.0.2\/mattermost-6.0.2-linux-amd64.tar.gz<\/pre>\n\n\n\nNow you have successfully downloaded the Mattermost file and now you will extract it to the \/opt<\/code><\/strong> directory using the tar command:<\/p>\n\n\n\ntar xvzf mattermost-6.0.2-linux-amd64.tar.gz -C \/opt\/<\/pre>\n\n\n\nNext, we need to make the directory where we\u2019ll store the files:<\/p>\n\n\n\n
sudo mkdir \/opt\/mattermost\/data<\/pre>\n\n\n\nNext, change the ownership and permissions of the Mattermost:<\/p>\n\n\n\n
chown -R mattermost:mattermost \/opt\/mattermost\nchmod -R g+w \/opt\/mattermost<\/pre>\n\n\n\nNext, edit the Mattermost configuration file and define your site URL and database settings:<\/p>\n\n\n\n
nano \/opt\/mattermost\/config\/config.json<\/pre>\n\n\n\nChange the following lines with your site domain name and database settings:<\/p>\n\n\n\n
\"SiteURL\": \"http:\/\/mattermost.example.com<\/code>\", \n\"DriverName\": \"MySQL\", \n\"DataSource\": \"mmuser:Str0ngPa$$worD@tcp(localhost:3306)\/mattermost?charset=utf8mb4,utf8&readTimeout=30s&writeTimeout=30s\",<\/pre>\n\n\n\nSave and close the file when you are done.<\/p>\n\n\n\n
<\/span>Step 5: Create a Systemd Service File for Mattermost<\/span><\/h2>\n\n\n\nNext, create a systemd service file to start and stop the Mattermost service.<\/p>\n\n\n\n
nano \/lib\/systemd\/system\/mattermost.service<\/pre>\n\n\n\nAdd the following lines:<\/p>\n\n\n\n
[Unit]\nDescription=Mattermost\nAfter=network.target\nAfter=mysql.service\nRequires=mysql.service\n\n[Service]\nType=notify\nUser=mattermost\nGroup=mattermost\nExecStart=\/opt\/mattermost\/bin\/mattermost\nTimeoutStartSec=3600\nRestart=always\nRestartSec=10\nWorkingDirectory=\/opt\/mattermost\nLimitNOFILE=49152\n\n[Install]\nWantedBy=mariadb.service\n<\/pre>\n\n\n\nSave and close the file then reload the systemd daemon to apply the configuration changes:<\/p>\n\n\n\n
systemctl daemon-reload<\/pre>\n\n\n\nNext, start the Mattermost service and enable it to start at system reboot:<\/p>\n\n\n\n
systemctl start mattermost\nsystemctl enable mattermost<\/pre>\n\n\n\nTo check and verify the status of your Mattermost service, run the following command:<\/p>\n\n\n\n
systemctl status mattermost<\/pre>\n\n\n\nOutput :<\/strong><\/p>\n\n\n\n\u25cf mattermost.service - Mattermost\nLoaded: loaded (\/etc\/systemd\/system\/mattermost.service; disabled; vendor preset: enabled)\nActive: active (running)\nMain PID: 831 (mattermost)\nTasks: 46 (limit: 2303)\nMemory: 331.0M\nCPU: 36.628s\nCGroup: \/system.slice\/mattermost.service\n\u251c\u2500831 \/opt\/mattermost\/bin\/mattermost\n\u251c\u2500861 plugins\/com.mattermost.plugin-channel-export\/server\/dist\/plugin-linux-amd64\n\u251c\u2500868 plugins\/com.mattermost.nps\/server\/dist\/plugin-linux-amd64\n\u251c\u2500875 plugins\/playbooks\/server\/dist\/plugin-linux-amd64\n\u2514\u2500882 plugins\/focalboard\/server\/dist\/plugin-linux-amd64<\/pre>\n\n\n\nBy default, Mattermost runs on port 8065. You can check it using the following command:<\/p>\n\n\n\n
ss -tunlp | grep 8065<\/pre>\n\n\n\nOutput:<\/p>\n\n\n\n
tcp LISTEN 0 4096 *:8065 *:* users:((\"mattermost\",pid=1049,fd=28))<\/pre>\n\n\n\n