Install Mattermost server from a tarball
Available on all plans
self-hosted deployments
These instructions outline how to install Mattermost Server on a 64-bit Linux host from a compressed tarball, and assume the IP address of the Mattermost server is 10.10.10.2.
Minimum system requirements
Hardware: 2 vCPUs/cores with 4GB RAM (support for 1,000-2,000 users)
Database: MySQL v8+ or PostgreSQL v12+
Network ports required:
Application ports 80/443, TLS, TCP Inbound
Administrator Console port 8065, TLS, TCP Inbound
SMTP port 10025, TCP/UDP Outbound
Deploy Generic Linux
Install and configure a MySQL or PostgreSQL database. Refer to one of the guides below to deploy the database based on your operating system:
Log in to the server that will host Mattermost Server and open a terminal window.
Download the latest version of the Mattermost Server. In the following command, replace
X.X.X
with the version that you want to download:wget https://releases.mattermost.com/X.X.X/mattermost-X.X.X-linux-amd64.tar.gz
Extract the Mattermost Server files.
tar -xvzf mattermost*.gz
Move the extracted file to the
/opt
directory.sudo mv mattermost /opt
Create the storage directory for files.
sudo mkdir /opt/mattermost/data
Note
The storage directory will contain all the files and images that your users post to Mattermost, so you need to make sure that the drive is large enough to hold the anticipated number of uploaded files and images.
Set up a system user and group called
mattermost
that will run this service, and set the ownership and permissions.
Create the Mattermost user and group.
sudo useradd --system --user-group mattermostSet the user and group mattermost as the owner of the Mattermost files.
sudo chown -R mattermost:mattermost /opt/mattermostGive write permissions to the mattermost group.
sudo chmod -R g+w /opt/mattermost
Set up the database driver in the file
/opt/mattermost/config/config.json
. Open the file in a text editor and make the following changes:If you’re using PostgreSQL:
Set
"DriverName"
to"postgres"
Set"DataSource"
to the following value, replacing<mmuser-password>
and<host-name-or-IP>
with the appropriate values:"postgres://mmuser:<mmuser-password>@<host-name-or-IP>:5432/mattermost?sslmode=disable&connect_timeout=10",
If you’re using MySQL:
Set
"DriverName"
to"mysql"
Set"DataSource"
to the following value, replacing<mmuser-password>
and<host-name-or-IP>
with the appropriate values. Also make sure that the database name ismattermost
instead ofmattermost_test
:"mmuser:<mmuser-password>@tcp(<host-name-or-IP>:3306)/mattermost?charset=utf8mb4,utf8&writeTimeout=30s"
Test the Mattermost server to make sure everything works.
Change to the Mattermost directory.
cd /opt/mattermost
Start the Mattermost server as the user mattermost.
sudo -u mattermost bin/mattermostWhen 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 on Windows or Linux, or ⌘ C on Mac, in the terminal window.
Set up Mattermost to use systemd for starting and stopping.
Create a systemd unit file.
sudo touch /lib/systemd/system/mattermost.serviceOpen the unit file as root in a text editor, and copy the following lines into the 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.targetNote
If you’re using MySQL, replace
postgresql.service
withmysql.service
in two places in the[Unit]
section.If you’ve installed MySQL or PostgreSQL on a dedicated server, you need to remove the
After=mysql.service
andBindsTo=mysql.service
or theAfter=postgresql.service
andBindsTo=postgresql.service
lines in the[Unit]
section or the Mattermost service won’t start.
Make systemd load the new unit.
sudo systemctl daemon-reloadCheck to make sure that the unit was loaded.
sudo systemctl status mattermost.serviceYou 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)
Start the service.
sudo systemctl start mattermost.serviceVerify that Mattermost is running.
curl http://localhost:8065You should see the HTML that’s returned by the Mattermost server. If a firewall is used, external requests to port 8065 may be blocked. Use
sudo ufw allow 8065
to open port 8065.
Set Mattermost to start on machine start up.
sudo systemctl enable mattermost.service
Once you’re Mattermost server is up and running, create your first Mattermost user, invite more users, and explore the Mattermost platform.