Mattermost is an open-source, self-hosted team messaging platform and a direct alternative to Slack. It is written in Go and React, supports MySQL or PostgreSQL as a database backend, and provides file sharing, direct and group messaging, custom emojis, and video calls — all under your own infrastructure and data policies.
This guide covers how to install Mattermost on Ubuntu 18.04 using MySQL as the database backend and Nginx as an SSL reverse proxy.
<strong>Prerequisites:</strong> You need sudo access, a domain pointing to your server, Nginx installed, and an SSL certificate.
Create the MySQL database and user. Log in to MySQL as root, then run:
sqlCREATE DATABASE mattermost;GRANT ALL ON mattermost.* TO mattermost@localhost IDENTIFIED BY 'strong-password-here';
Create a dedicated system user. The -M flag skips home directory creation because Mattermost’s working directory (/opt/mattermost) is created from the tarball extraction:
bashsudo useradd -U -M -d /opt/mattermost mattermost
Download the Mattermost binary and set up the directory structure:
bashsudo curl -L https://releases.mattermost.com/5.1.0/mattermost-5.1.0-linux-amd64.tar.gz -o /tmp/mattermost.tar.gzsudo tar zxf /tmp/mattermost.tar.gz -C /optsudo mkdir -p /opt/mattermost/datasudo chown -R mattermost: /opt/mattermost
The data directory stores uploaded files and attachments. Mattermost will not start without it.
Configure the database connection. Open /opt/mattermost/config/config.json and set the database driver and connection string in the SqlSettings block:
json"DriverName": "mysql","DataSource": "mattermost:strong-password-here@tcp(localhost:3306)/mattermost?charset=utf8mb4,utf8&readTimeout=30s&writeTimeout=30s"
The charset=utf8mb4 parameter is required for full Unicode support including emoji. Without it, emoji in messages cause database write errors.
Test the configuration before creating the systemd service:
bashcd /opt/mattermostsudo -u mattermost bin/mattermost
If the server starts and shows Server is listening on [::]:8065, the database connection is working. Press Ctrl+C to stop it.
Create /etc/systemd/system/mattermost.service:
ini[Unit]Description=MattermostAfter=network.targetAfter=mysql.serviceRequires=mysql.service[Service]Type=notifyExecStart=/opt/mattermost/bin/mattermostTimeoutStartSec=3600Restart=alwaysRestartSec=10WorkingDirectory=/opt/mattermostUser=mattermostGroup=mattermostLimitNOFILE=49152
Two directives deserve attention: Type=notify means Mattermost sends a readiness signal to systemd when it is fully started, preventing dependent services from proceeding too early. LimitNOFILE=49152 raises the file descriptor limit beyond the default 1024 — Mattermost keeps one file descriptor open per active WebSocket connection, so this headroom is necessary for teams with many simultaneous users.
bashsudo systemctl daemon-reloadsudo systemctl start mattermostsudo systemctl enable mattermost
Configure Nginx. Create /etc/nginx/conf.d/example.com.conf. The configuration needs two upstream blocks: mattermost_backend on port 8065. Two location blocks handle different traffic types:
/api/v[0-9]+/(users/)?websocket$) requires Upgrade: $http_upgrade and Connection: upgrade headers because WebSocket connections start as HTTP and then upgrade to a persistent bidirectional protocol/) handles all other requests with proxy caching enabledInclude your SSL certificate paths and HTTP to HTTPS and WWW to non-WWW redirect server blocks. Reload Nginx when done.
Open https://your-domain in a browser. The first account you create becomes the system administrator. Create this account before sharing the URL with your team.
The setup wizard asks you to create an initial team and set its web address. After completing it, you land on the Mattermost dashboard.
Set the Site URL. Open the System Console (click your username, then System Console) and navigate to General > Configuration. Set the Site URL to your exact domain, including https://. Mattermost uses this for notification links and email formatting.
Enable email notifications under Notifications > Email. Set Enable Email Notifications to true and enter your SMTP server parameters. Mattermost supports any transactional email provider including SendGrid, Amazon SES, Mailgun, and Postmark.
Restart Mattermost after saving System Console settings: sudo systemctl restart mattermost.
Mattermost is now installed and running on Ubuntu 18.04 with Nginx as the SSL proxy. Your team can now communicate through a self-hosted platform you fully control. Leave a comment below if you run into any issues.
Ruby is a dynamic, open-source programming language known for its clean, readable syntax. It powers the…
PyCharm is a full-featured Python IDE developed by JetBrains. It includes built-in debugging, embedded Git control,…
PHP 8.5 is included in Ubuntu 26.04's default repositories and is the recommended version for…
Ubuntu 26.04 LTS "Resolute Raccoon" arrived on April 23, 2026 with Linux kernel 7.0, GNOME 50,…
Kubernetes is the standard platform for running containerized workloads across multiple servers with self-healing, rolling…
Ubuntu 26.04 LTS "Resolute Raccoon" was released on April 23, 2026 with Linux kernel 7.0, GNOME desktop, and standard security support until April 2031. A clean install gives you a known-good starting point on new hardware, when replacing another operating system, or when an upgrade path is not practical. This guide walks through how to install Ubuntu 26.04: downloading and verifying the ISO, writing a bootable USB drive, completing the installer, and doing the initial setup after the first boot. Before you start: You need a USB drive with at least 12 GB of free space. Back up any existing data on the target machine — the installer can erase the entire disk. Install Ubuntu 26.04: Download the ISO…