How to Install Docker on Debian 10

Docker is an OS-level virtualization solution built around Linux kernel features like namespaces and cgroups to provide isolation for software packages called containers. This article will walk you through the process of installing and starting Docker on your Debian 10 server.

Prerequisites:

  • You need access to a Linux server, with sudo or root privileges.

Installation:

Before installing the Docker package, we will ensure the package cache is up to date.

$ sudo apt-get update

We will then install some needed dependencies.

$ sudo apt-get install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common

Next up, we need to import the gpg public key for the Docker CE repository

$ curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -

Now that the gpg public key has been added, we can add the Docker CE repository.

$ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable"

Update the package cache to recognize the new repository.

$ sudo apt-get update

Install the Docker-CE package.

$ sudo apt-get install -y docker-ce docker-ce-cli containerd.io

Configuration:

First, we must configure a user if we want to run docker without root privileges.  I have created a user called test_user.  The following command will add the user “test_user” to the docker group.

$ sudo usermod -a -G docker test_user

In order for the changes to be recognized, you must log out and back into your existing shell session or use the following command.

$ su test_user

Verification:

We can use systemctl to ensure the docker service is started and set to enabled at boot.

$s udo systemctl status docker.service

Check which docker version is installed.

$ docker --version

Run a test container. If this completes successfully, then you have successfully configured the docker service.

$ docker run hello-world

Conclusion

In this article, you learned how to install, configure, and verify the docker service on Debian 10.  Check out the official docker documentation for more information.

How to Install Docker on Centos 7

Docker is an OS-level virtualization solution built around Linux kernel features like namespaces and cgroups to provide isolation for software packages called containers. In this article, we’ll be walking through the installation of Docker on CentOS 7.

Prerequisites:

  •     You need access to a Linux server, with sudo or root privileges.

Installation:

We will be using yum-config-manager to setup Docker’s repository. The yum-config-manager command is in the yum-utils package. We will start off by installing yum-utils.

$ sudo yum install -y yum-utils

We can now add the Docker repository using yum-config-manager.

$ sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

Install the Docker-CE package.

$ sudo yum install docker-ce docker-ce-cli containerd.io

Configuration:

First, we must configure a user if we want to run docker without root privileges.  I have created a user called test_user.  The following command will add the user “test_user” to the docker group.

$ sudo usermod -a -G docker test_user

In order for the changes to be recognized, you must log out and back into your existing shell session or use the following command.

$ su test_user

Verification:

We can use systemctl to ensure the docker service is started and set to enabled at boot.

$ sudo systemctl status docker.service

It is neither started or enabled at boot.

Start Docker.

$ sudo systemctl start docker

Enable Docker at boot.

$ sudo systemctl enable

Check which docker version is installed.

$ docker --version

Run a test container. If this completes successfully, then you have successfully configured the docker service.

$ docker run hello-world

Conclusion

In this article, you learned how to install, configure, and verify the docker service on Centos 7.  Check out the official Docker documentation for more information.

Installing Nginx on Windows Server

Nginx is a web-server service which has gained almost as much market share as Apache in recent years due to its excellent performance and flexible feature set.  This guide will go through installation instructions and discuss next steps in setting up Nginx to serve your site or application.

Prerequisites:

• A server running a version of Windows Server

Installing Nginx on Windows Server

Nginx comes pre-compiled direct from their website, which makes installation as simple as downloading and extracting the file.  You should grab the latest mainline release for Windows from the link below

http://nginx.org/en/download.html

Once downloaded, simply extract the file to the location you wish to install Nginx at.  We recommend creating a directory for Nginx to live in such as:

C:nginx

Test Nginx

Open a CMD prompt and start Nginx with the following:

C:nginxnginx.exe

Be sure to replace the path if you did not install Nginx in the example directory.  Now you should be able to navigate to http://localhost/ within the server’s web browser and see the Nginx default web page.  If you see “Welcome to Nginx” everything is working as intended.

Items to note for Nginx on Windows

The Nginx project considers the Windows release for Nginx to be in beta.  It is functionally similar to the Unix releases but some features are missing.  See the link below for more specific details on this.

http://nginx.org/en/docs/windows.html

It is also worth noting that Nginx does not run as a service in Windows, so it will not restart automatically based on your settings within the Local Services options.

Next Steps

Nginx is now installed and ready to start serving your application or website.  If you wish to serve more than one site it is recommended that you set up Nginx server blocks to accommodate.

Installing Nginx on CentOS

Nginx is a web-server service which has gained almost as much market share as Apache in recent years due to its excellent performance and flexible feature set.  This guide will go through installation instructions and discuss next steps in setting up Nginx to serve your site or application.

Prerequisites:

• Linux server running CentOS

Installing Nginx on CentOS

Nginx is available in the default repositories for most popular Linux distributions including CentOS.  As such installing it is as simple as running the following dnf package-manager command:

sudo dnf install nginx

Be sure to hit ‘y’ for the Y/N prompt to confirm that you wish to install the package.

After dnf finishes installing the packages, Nginx has been installed.  However, we are not done quite yet.  You should also enable and start the service.  This both sets up Nginx to startup when the server does, as well as starting it up now for further configuration and testing.

sudo systemctl enable nginx
sudo systemctl start nginx

Open the firewall for Nginx

By default Nginx will be configured to listen on the default ports for HTTP and HTTPS traffic, 80 and 443 respectively.  However, this does not mean that it will receive traffic, as the firewall on the system will need to also allow traffic on these ports.  We recommend adding the ports needed for your site or application, namely HTTP and/or HTTPS:

sudo firewall-cmd --permanent --add-service=http

sudo firewall-cmd --permanent --add-service=https

Then reload firewalld to apply the new settings:

sudo firewall-cmd --reload

Test Nginx

Once the package is installed and the firewall port or ports are open Nginx should be displaying its default webpage.  You can see this by typing in your IP address in your web browser.  You should see a splash page with Nginx’s logo and a “Welcome to Nginx” message.  If you do not see this, double check the IP, that Nginx is running, and the firewall settings.  

Next Steps

Nginx is now installed and ready to start serving your application or website.  You can utilize the default configuration to serve a site by placing its content at /var/www/html in your filesystem.  However, if you wish to serve more than one site it is recommended that you set up Nginx server blocks to accommodate.

Installing Nginx on Ubuntu

Nginx is a web-server service which has gained almost as much market share as Apache in recent years due to its excellent performance and flexible feature set.  This guide will go through installation instructions and discuss next steps in setting up Nginx to serve your site or application.

Prerequisites:

• Linux server running Ubuntu

Installing Nginx on Ubuntu

Nginx is available in the default repositories for most popular Linux distributions including Ubuntu.  As such installing it is as simple as running the following apt package-manager commands:

sudo apt update
sudo apt install nginx

Running update before installing new packages is a best practice, as it allows apt to grab the latest package listings.  This allows the most up-to-date version of the package available on the repository to be the one chosen for installation.

After apt finishes installing the packages, Nginx has been installed.  However, we are not done quite yet.  You should also enable and start the service.  This both sets up Nginx to startup when the server does, as well as starting it up now for further configuration and testing.

sudo systemctl enable nginx
sudo systemctl start nginx

Open the firewall for Nginx

By default Nginx will be configured to listen on the default ports for HTTP and HTTPS traffic, 80 and 443 respectively.  However, this does not mean that it will receive traffic, as the firewall on the system will need to also allow traffic on these ports.  Luckily, Nginx makes this easy for us as it registers itself as a service within UFW.  Thus we can simply enable the service on UFW.  Run the following to see what services are available on UFW:

sudo ufw app list

You should see three options for Nginx, Full, HTTP, and HTTPS.  These services represent both HTTP and HTTPS traffic, just HTTP traffic, and just HTTPS traffic.  Enable the one that is appropriate for your site.  Please note if you wish to have a redirect from HTTP to HTTPS you will want to select Full in this list.  Then simply enable your selection with the following:

sudo ufw allow 'Nginx '

Please replace the with the option best suited for your needs.  We recommend only opening the port or ports needed by your application, as minimizing the number of available ports is a security best practice.

Test Nginx

Once the package is installed and the firewall port or ports are open Nginx should be displaying its default webpage.  You can see this by typing in your IP address in your web browser.  You should see a splash page with Nginx’s logo and a “Welcome to Nginx” message.  If you do not see this, double check the IP, that Nginx is running, and the firewall settings.  

Next Steps

Nginx is now installed and ready to start serving your application or website.  You can utilize the default configuration to serve a site by placing its content at /var/www/html in your filesystem.  However, if you wish to serve more than one site it is recommended that you set up Nginx server blocks to accommodate.

Installing Nginx on Fedora

Nginx is a web-server service which has gained almost as much market share as Apache in recent years due to its excellent performance and flexible feature set.  This guide will go through installation instructions and discuss next steps in setting up Nginx to serve your site or application.

Prerequisites:

• Linux server running Fedora

Installing Nginx on Fedora

Nginx is available in the default repositories for most popular Linux distributions including Fedora.  As such installing it is as simple as running the following dnf package-manager command:

sudo dnf install nginx

Be sure to hit ‘y’ for the Y/N prompt to confirm that you wish to install the package.

After dnf finishes installing the packages, Nginx has been installed.  However, we are not done quite yet.  You should also enable and start the service.  This both sets up Nginx to startup when the server does, as well as starting it up now for further configuration and testing.

sudo systemctl enable nginx
sudo systemctl start nginx

Open the firewall for Nginx

By default Nginx will be configured to listen on the default ports for HTTP and HTTPS traffic, 80 and 443 respectively.  However, this does not mean that it will receive traffic, as the firewall on the system will need to also allow traffic on these ports.  Add the ports necessary for your site by adding the HTTP and/or HTTPS services:

sudo firewall-cmd --permanent --add-service=http

sudo firewall-cmd --permanent --add-service=https

Then reload firewalld to apply the new settings:

sudo firewall-cmd --reload

Test Nginx

Once the package is installed and the firewall port or ports are open Nginx should be displaying its default webpage.  You can see this by typing in your IP address in your web browser.  You should see a splash page with Nginx’s logo and a “Welcome to Nginx” message.  If you do not see this, double check the IP, that Nginx is running, and the firewall settings.  

Next Steps

Nginx is now installed and ready to start serving your application or website.  You can utilize the default configuration to serve a site by placing its content at /var/www/html in your filesystem.  However, if you wish to serve more than one site it is recommended that you set up Nginx server blocks to accommodate.

How to Install Jitsi on Debian 10

This guide will walk you through the process of installing Jitsi on your Linux server running Debian 10. Jitsi is a collection of free and open-source multi-platform voice, videoconferencing and instant messaging applications for the web platform, Windows, Linux, Mac OS X, and Android.

Prerequisites:

Linux Server Running Debian 10

Step-by-Step:

1) The first thing we’ll do is setup a swap file for out server to utilize in order to avoid memory starvation. The following collection of commands will create and setup this swap space. If your server has more than 2GB of memory, this likely won’t be necessary.

sudo dd if=/dev/zero of=/swapfile count=2048 bs=1M
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
echo '/swapfile   none    swap    sw    0   0' | sudo tee -a /etc/fstab

Now, just run the free -m command to check whether our swap space is listed:

free -m

2) If you plan to use HTTPS in order to access your video conferencing rooms over Jitsi, it’s important to set up a proper fully qualified domain name. The following commands will set the hostname and fully qualified domain name for the server. In our example, we’ll use jitsi.server.com as the fully qualified domain name, and jitsiserver as the hostname. Be sure to replace these values with your own.

sudo hostnamectl set-hostname jitsiserver
sudo sed -i 's/^127.0.1.1.*$/127.0.1.1 jitsi.server.com jitsiserver/g' /etc/hosts

After this is done,  run the following command to ensure we see the proper hostnames set.

hostname

3) Now we need to configure our firewall to allow traffic over OpenSSH, http, https, and other ports required for Jitsi to operate. The following commands will open these ports, and save the changes:

iptables -I INPUT -p tcp --dport 80 -j ACCEPT
iptables -I INPUT -p tcp --dport 443 -j ACCEPT
iptables -I INPUT -p udp --dport 20000 -j ACCEPT
iptables -I INPUT -p udp --dport 10000 -j ACCEPT

4) Next, we need to install OpenJDK 8, to do this we’ll enable the AdoptOpenJDK repository, which will provide us the OpenJDK packages. We’ll start by updating the packages list and installing the dependencies necessary to add a new repository:

sudo apt update
sudo apt install apt-transport-https ca-certificates wget dirmngr gnupg software-properties-common

5) Now we’ll import the repository’s GPG key using the following commands:

wget -qO - https://adoptopenjdk.jfrog.io/adoptopenjdk/api/gpg/key/public | sudo apt-key add -
sudo add-apt-repository --yes https://adoptopenjdk.jfrog.io/adoptopenjdk/deb/

6) Once the new repository is enabled, update apt sources and install Java 8 using the following commands:

sudo apt update
sudo apt install adoptopenjdk-8-hotspot

7) Finally, we can check to ensure you installed it successfully by looking at the output from the following command:

java -version

8) Our next step is to install Nginx, which is the web service that will operate as the front end for our Jitsi application. The collection of commands will install, start, and set Nginx to start on boot:

sudo apt install -y nginx
sudo systemctl start nginx.service
sudo systemctl enable nginx.service

9) Now we’re ready to install Jitsi itself. Let’s be sure we’re backed out of any subdirectories before we download and install the software by running the following:

cd

Next, we’ll issue the following commands to add our Jitsi repository to our sources.list, and then download Jitsi and start the service:

wget -qO - https://download.jitsi.org/jitsi-key.gpg.key | sudo apt-key add -
sudo sh -c "echo 'deb https://download.jitsi.org stable/' > /etc/apt/sources.list.d/jitsi-stable.list"
sudo apt update -y
sudo apt install -y jitsi-meet

10) When we first do ‘apt install -y’ for Jitsi-Meet we’ll be prompted to enter our fully qualified domain name. This should be the same domain name we entered on step 2.

After pressing ENTER you are asked about an SSL certificate. For this guide, we’ll be choosing “Generate a new self-signed certificate (You will later get a chance to obtain a Let’s Encrypt certificate)”.

Once you’ve finished going through the install, if you want to proceed with obtaining a certificate from Let’s Encrypt, you can use the following script provided by Jitsi:

sudo /usr/share/jitsi-meet/scripts/install-letsencrypt-cert.sh

It will prompt you for an email address when you run it, then it will automatically handle the remaining work related to the Let’s Encrypt SSL certificate.

11) Finally, you’re ready to point your DNS over to the Jitsi server. Once you’ve done this, navigate to the URL you direct to the server will present you with the front-end of the Jitsi application. Pressing ‘GO’ will create a video conference room for you.

For any further assistance with Jitsi, or questions you may have, check out their Community Forum.

How to Install Mattermost on Fedora 31

This article will cover the installation of Mattermost on an Fedora 31 Linux server. Mattermost is an open-source, self-hostable online chat service with file sharing, search, and integrations. It is designed to be used as an internal chat for organizations and companies and could be considered an open-source alternative to Slack and Microsoft Teams.

Prerequisites:

Access to a Linux server running Fedora 31

Step-by-Step:

This part of the article will walk you through installing Mattermost and it’s dependencies.

Part One: Installing the MySQL Database

1) Log into your Fedora 31 server as root or a sudo user

2) Run the following command to install MySQL:

sudo dnf install mariadb mariadb-server

3) Now we need to log into MySQL as root using the following:

sudo mysql

4) Once you see ‘mysql>’ in the prompt, you’ve entered the database. Now we need to create a user and password. Execute the following commands, but replace mmuser and mmuser-password with unique identifiers:

create user 'mmuser'@'%' identified by 'mmuser-password';

Also, it’s worth noting that the % indicates that this user can connect from a device with any IP address. If you know the IP this user will be connecting from, it’s more secure to change the % to that IP address.

5) While we’re still in the MySQL prompt, we need to create a database and grant permissions to that database for our new user. The commands below will accomplish this:

create database mattermost;
grant all privileges on mattermost.* to 'mmuser'@'%';

6) Now that we’ve installed and set up our database, we can exit MySQL to get back to the Linux command prompt by running the command below:

exit

Part Two: Installing Mattermost

1) Download the latest version of the Mattermost Server. Navigating to this URL and scrolling down should display a URL just below the ‘GET DOWNLOAD’ button. Copy this URL and within your server’s terminal execute the following command:

wget https://releases.mattermost.com/X.X.X/mattermost-X.X.X-linux-amd64.tar.gz

In our example, we’ve replaced version numbers with X’s, but the URL you copied should contain these version numbers.

2) Now we need to extract the files we’ve downloaded using the following:

tar -xvzf mattermost*.gz

3) Once we’ve extracted the files, we need to move them to the /opt directory using the command below:

sudo mv mattermost /opt

4) Next, we need to make the directory where we’ll store the files:

sudo mkdir /opt/mattermost/data

5) We’ll need to create a user dedicated to the Mattermost service, which will be the one running Mattermost and owner of the related files and directories. The following commands will create the user, group, and set the permissions:

sudo useradd --system --user-group mattermost

sudo chown -R mattermost:mattermost /opt/mattermost

sudo chmod -R g+w /opt/mattermost

6) Next, we’ll have to set up the database driver in the file /opt/mattermost/config/config.json by making some changes to its contents. Open the file in your preferred text editor and then look for and adjust the following values:

  • Set “DriverName” to “mysql”
  • Set “DataSource” to the following value “mmuser:mmuser-password@tcp(:3306)/mattermost?charset=utf8mb4,utf8&readTimeout=30s&writeTimeout=30s”
  • Set “SiteURL” to the full URL you plan to use for your Mattermost site. You need to include http:// or https://

Be sure on the “DataSource” edit that you only change the to the public IP of your server if the database is remote to the server where Mattermost is installed. If they live on the same server, then set it to localhost:3306

7) Now we’ll test out our Mattermost application. Navigate to the following directory:

cd /opt/mattermost

    And run the following command to start Mattermost:

sudo -u mattermost ./bin/mattermost

    When the server starts, it shows some log information and the text Server is listening on :8065. You can stop the server by pressing CTRL+C in the terminal window.

8) Now that we’ve confirmed the server starts without issue, we need to configure Mattermost to use systemd for starting and stopping. First, we’ll create a new systemd unit file using the following command:

sudo touch /lib/systemd/system/mattermost.service

9) Now open that file in your text editor and paste the following into the file. Once you’ve made the change, save the file and exit:

[Unit]
Description=Mattermost
After=network.target
After=mysqld.service
Requires=mysqld.service

[Service]
Type=notify
ExecStart=/opt/mattermost/bin/mattermost
TimeoutStartSec=3600
Restart=always
RestartSec=10
WorkingDirectory=/opt/mattermost
User=mattermost
Group=mattermost
LimitNOFILE=49152

[Install]
WantedBy=mysqld.service

10) Now we need to make systemd load the new unit and we’ll use systemctl to test our new unit file:

sudo systemctl daemon-reload

sudo systemctl status mattermost.service

You should see an output similar to the following:

● mattermost.service - Mattermost
  Loaded: loaded (/lib/systemd/system/mattermost.service; disabled; vendor preset: enabled)
  Active: inactive (dead)

11) If you receive the expected response, we can start the service:

sudo systemctl start mattermost.service

12) Now, test and see whether the service is running:

curl http://localhost:8065

You should see the HTML that’s returned by the Mattermost server.

13) Finally, we can set Mattermost to start on boot:

sudo systemctl enable mattermost.service

From here on, most of the configuration will be handled within the browser on the Mattermost site itself and it’s provided panel. You can navigate to http://your-url-for-mattermost:8056 and follow the prompts to configure your first Mattermost user, which will be granted administrator privileges. You can continue using the Mattermost panel to configure Mattermost for your team’s needs. This is where you’ll be able to set up things like users, email notifications, image and file storage location, and assigning administrators for Mattermost. For further reading on Mattermost, please refer to their official knowledge base.

How to Install Jitsi on Ubuntu 18.04

This guide will walk you through the process of installing Jitsi on your Linux server running Ubuntu 18.04. Jitsi is a collection of free and open-source multi-platform voice, videoconferencing and instant messaging applications for the web platform, Windows, Linux, Mac OS X, and Android.

Prerequisites:

Linux Server Running Ubuntu 18.04

Step-by-Step:

1) The first thing we’ll do is setup a swap file for out server to utilize in order to avoid memory starvation. The following collection of commands will create and setup this swap space. If your server has more than 2GB of memory, this likely won’t be necessary.

sudo dd if=/dev/zero of=/swapfile count=2048 bs=1M
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
echo '/swapfile   none    swap    sw    0   0' | sudo tee -a /etc/fstab

Now, just run the free -m command to check whether our swap space is listed:

free -m

2) If you plan to use HTTPS in order to access your video conferencing rooms over Jitsi, it’s important to set up a proper fully qualified domain name. The following commands will set the hostname and fully qualified domain name for the server. In our example, we’ll use jitsi.server.com as the fully qualified domain name, and jitsiserver as the hostname. Be sure to replace these values with your own.

sudo hostnamectl set-hostname jitsiserver
sudo sed -i 's/^127.0.1.1.*$/127.0.1.1 jitsi.server.com jitsiserver/g' /etc/hosts

After this is done,  run the following command to ensure we see the proper hostnames set.

hostname

3) Now we need to configure our firewall to allow traffic over OpenSSH, http, https, and other ports required for Jitsi to operate. The following commands will open these ports, and save the changes:

sudo ufw allow OpenSSH
sudo ufw allow http
sudo ufw allow https
sudo ufw allow in 10000:20000/udp
sudo ufw enable

4) Now it’s time to install the applications Jitsi needs in order to function. First, it’s a good idea to update our repositories to ensure we’re downloading the latest available packages:

sudo apt update

5) Next, we’ll install the OpenJDK Java Runtime Environment  with the following command:

sudo apt install -y openjdk-8-jre-headless

You can check to ensure you installed it successfully by looking at the output from the following command:

java -version

6) Our next step is to install Nginx, which is the web service that will operate as the front end for our Jitsi application. The collection of commands will install, start, and set Nginx to start on boot:

sudo apt install -y nginx
sudo systemctl start nginx.service
sudo systemctl enable nginx.service

7) Now we’re ready to install Jitsi itself. Let’s be sure we’re backed out of any subdirectories before we download and install the software by running the following:

cd

Next, we’ll issue the following commands to add our Jitsi repository to our sources.list, and then download Jitsi and start the service:

wget -qO - https://download.jitsi.org/jitsi-key.gpg.key | sudo apt-key add -
sudo sh -c "echo 'deb https://download.jitsi.org stable/' > /etc/apt/sources.list.d/jitsi-stable.list"
sudo apt update -y
sudo apt install -y jitsi-meet
service jitsi-meet start

8) When we first start Jitsi-Meet we’ll be prompted to enter our fully qualified domain name. This should be the same domain name we entered on step 2.

After pressing ENTER you are asked about an SSL certificate. For this guide, we’ll be choosing “Generate a new self-signed certificate (You will later get a chance to obtain a Let’s Encrypt certificate)”.

Once you’ve finished going through the install, if you want to proceed with obtaining a certificate from Let’s Encrypt, you can use the following script provided by Jitsi:

sudo /usr/share/jitsi-meet/scripts/install-letsencrypt-cert.sh

It will prompt you for an email address when you run it, then it will automatically handle the remaining work related to the Let’s Encrypt SSL certificate.

9) Finally, you’re ready to point your DNS over to the Jitsi server. Once you’ve done this, navigate to the URL you direct to the server will present you with the front-end of the Jitsi application. Pressing ‘GO’ will create a video conference room for you.

For any further assistance with Jitsi, or questions you may have, check out their Community Forum.

How to Install Mattermost on Debian 10

This article will cover the installation of Mattermost on an Debian 10 Linux server. Mattermost is an open-source, self-hostable online chat service with file sharing, search, and integrations. It is designed to be used as an internal chat for organizations and companies and could be considered an open-source alternative to Slack and Microsoft Teams.

Prerequisites:

Access to a Linux server running Debian 10

Step-by-Step:

This part of the article will walk you through installing Mattermost and it’s dependencies.

Part One: Installing the MySQL Database

1) Log into your Debian 10 server as root or a sudo user

2) Run the following command to install MySQL:

# sudo apt install mariadb-server mariadb-client

3) Execute the command below to go through the Secure Installation. Follow the prompts provided by the wizard:

# sudo mysql_secure_installation

4) Now we need to log into MySQL as root using the following:

#sudo mysql

5) Once you see ‘mysql>’ in the prompt, you’ve entered the database. Now we need to create a user and password. Execute the following commands, but replace mmuser and mmuser-password with unique identifiers:

create user 'mmuser'@'%' identified by 'mmuser-password';

Also, it’s worth noting that the % indicates that this user can connect from a device with any IP address. If you know the IP this user will be connecting from, it’s more secure to change the % to that IP address.

6) While we’re still in the MySQL prompt, we need to create a database and grant permissions to that database for our new user. The commands below will accomplish this:

create database mattermost;
grant all privileges on mattermost.* to 'mmuser'@'%';

7) Now that we’ve installed and set up our database, we can exit MySQL to get back to the Linux command prompt by running the command below:

exit

Part Two: Installing Mattermost

1) Download the latest version of the Mattermost Server. Navigating to this URL and scrolling down should display a URL just below the ‘GET DOWNLOAD’ button. Copy this URL and within your server’s terminal execute the following command:

wget https://releases.mattermost.com/X.X.X/mattermost-X.X.X-linux-amd64.tar.gz

In our example, we’ve replaced version numbers with X’s, but the URL you copied should contain these version numbers.

2) Now we need to extract the files we’ve downloaded using the following:

tar -xvzf mattermost*.gz

3) Once we’ve extracted the files, we need to move them to the /opt directory using the command below:

sudo mv mattermost /opt

4) Next, we need to make the directory where we’ll store the files:

sudo mkdir /opt/mattermost/data

5) We’ll need to create a user dedicated to the Mattermost service, which will be the one running Mattermost and owner of the related files and directories. The following commands will create the user, group, and set the permissions:

sudo useradd --system --user-group mattermost

sudo chown -R mattermost:mattermost /opt/mattermost

sudo chmod -R g+w /opt/mattermost

6) Next, we’ll have to set up the database driver in the file /opt/mattermost/config/config.json by making some changes to its contents. Open the file in your preferred text editor and then look for and adjust the following values:

  • Set “DriverName” to “mysql”
  • Set “DataSource” to the following value “mmuser:mmuser-password@tcp(:3306)/mattermost?charset=utf8mb4,utf8&readTimeout=30s&writeTimeout=30s”
  • Set “SiteURL” to the full URL you plan to use for your Mattermost site. You need to include http:// or https://

Be sure on the “DataSource” edit that you only change the to the public IP of your server if the database is remote to the server where Mattermost is installed. If they live on the same server, then set it to localhost:3306

7) Now we’ll test out our Mattermost application. Navigate to the following directory:

cd /opt/mattermost

    And run the following command to start Mattermost:

sudo -u mattermost ./bin/mattermost

    When the server starts, it shows some log information and the text Server is listening on :8065. You can stop the server by pressing CTRL+C in the terminal window.

8) Now that we’ve confirmed the server starts without issue, we need to configure Mattermost to use systemd for starting and stopping. First, we’ll create a new systemd unit file using the following command:

sudo touch /lib/systemd/system/mattermost.service

9) Now open that file in your text editor and paste the following into the file. Once you’ve made the change, save the file and exit:

[Unit]
Description=Mattermost
After=network.target
After=mysql.service
Requires=mysql.service

[Service]
Type=notify
ExecStart=/opt/mattermost/bin/mattermost
TimeoutStartSec=3600
Restart=always
RestartSec=10
WorkingDirectory=/opt/mattermost
User=mattermost
Group=mattermost
LimitNOFILE=49152

[Install]
WantedBy=mysql.service

10) Now we need to make systemd load the new unit and we’ll use systemctl to test our new unit file:

sudo systemctl daemon-reload

sudo systemctl status mattermost.service

You should see an output similar to the following:

● mattermost.service - Mattermost
  Loaded: loaded (/lib/systemd/system/mattermost.service; disabled; vendor preset: enabled)
  Active: inactive (dead)

11) If you receive the expected response, we can start the service:

sudo systemctl start mattermost.service

12) Now, test and see whether the service is running:

curl http://localhost:8065

You should see the HTML that’s returned by the Mattermost server.

13) Finally, we can set Mattermost to start on boot:

sudo systemctl enable mattermost.service

From here on, most of the configuration will be handled within the browser on the Mattermost site itself and it’s provided panel. You can navigate to http://your-url-for-mattermost:8056 and follow the prompts to configure your first Mattermost user, which will be granted administrator privileges. You can continue using the Mattermost panel to configure Mattermost for your team’s needs. This is where you’ll be able to set up things like users, email notifications, image and file storage location, and assigning administrators for Mattermost. For further reading on Mattermost, please refer to their official knowledge base.