Install Mattermost server
Install Mattermost Server on a 64-bit machine. Assume that the IP address of this server is 10.10.10.2
.
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 *.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.
sudo useradd --system --user-group mattermost
sudo chown -R mattermost:mattermost /opt/mattermost
sudo chmod -R g+w /opt/mattermost
sudo restorecon -R /opt/mattermost
Set up the database driver in the file
/opt/mattermost/config/config.json
. Open the file as root in a text editor and make the following changes:
If you are 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 are 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"
Note
For a same-machine installation, replace
<host-name-or-IP>
above withlocalhost
or127.0.0.1
.
Also set
"SiteURL"
to the full base URL of the site (e.g."https://mattermost.example.com"
).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/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 pressing Ctrl C on Windows or Linux, or ⌘ C on Mac, in the terminal window.
Set up Mattermost to use the
systemd init
daemon which handles supervision of the Mattermost process.
Create the Mattermost configuration file:
sudo touch /etc/systemd/system/mattermost.service
Open the configuration file in a text editor, and copy the following lines into the file:
[Unit] Description=Mattermost After=syslog.target network.target postgresql.service [Service] Type=notify WorkingDirectory=/opt/mattermost User=mattermost ExecStart=/opt/mattermost/bin/mattermost PIDFile=/var/spool/mattermost/pid/master.pid TimeoutStartSec=3600 KillMode=mixed LimitNOFILE=49152 [Install] WantedBy=multi-user.targetNote
If you are using MySQL, replace
postgresql.service
withmysqld.service
in the[unit]
section.
Set the service file permissions.
sudo chmod 644 /etc/systemd/system/mattermost.service
Reload the systemd services.
sudo systemctl daemon-reload
Set Mattermost to start on boot.
sudo systemctl enable mattermost
Start the Mattermost server.
sudo systemctl start mattermost
Verify that Mattermost is running.
curl http://localhost:8065
You should see the HTML that’s returned by the Mattermost server.
Now that Mattermost is installed and running, it’s time to create the admin user and configure Mattermost for use.