Skip to main content

Self-Hosting Guide: Deploy Mattermost on Your Own Server

·OSSAlt Team
mattermostteam chatself-hostingdockerguide

Self-Hosting Guide: Deploy Mattermost on Your Own Server

Mattermost is the open source Slack alternative. Self-hosting gives you unlimited users, full data ownership, and costs only the price of a VPS. Here's the complete production setup.

Requirements

  • VPS with 4 GB RAM minimum
  • Docker and Docker Compose
  • Domain name (e.g., chat.yourdomain.com)
  • 20+ GB disk for file attachments

Step 1: Clone the Official Docker Setup

git clone https://github.com/mattermost/docker.git mattermost-docker
cd mattermost-docker

# Create data directories
mkdir -p ./volumes/app/mattermost/{config,data,logs,plugins,client/plugins,bleve-indexes}
sudo chown -R 2000:2000 ./volumes/app/mattermost

# Copy environment
cp env.example .env

Step 2: Configure

Edit .env:

# Domain
DOMAIN=chat.yourdomain.com

# Database
POSTGRES_USER=mmuser
POSTGRES_PASSWORD=your-strong-password
POSTGRES_DB=mattermost

# Mattermost
MM_SQLSETTINGS_DRIVERNAME=postgres
MM_SQLSETTINGS_DATASOURCE=postgres://mmuser:your-strong-password@db:5432/mattermost?sslmode=disable&connect_timeout=10

# File storage
MM_FILESETTINGS_DRIVERNAME=local
MM_FILESETTINGS_DIRECTORY=/mattermost/data

# SMTP (for email notifications)
MM_EMAILSETTINGS_SMTPSERVER=smtp.resend.com
MM_EMAILSETTINGS_SMTPPORT=587
MM_EMAILSETTINGS_SMTPUSERNAME=resend
MM_EMAILSETTINGS_SMTPPASSWORD=re_your_api_key
MM_EMAILSETTINGS_CONNECTIONSECURITY=STARTTLS
MM_EMAILSETTINGS_FEEDBACKEMAIL=mattermost@yourdomain.com

Step 3: Start Mattermost

docker compose -f docker-compose.yml -f docker-compose.without-nginx.yml up -d

Step 4: Reverse Proxy (Caddy)

# /etc/caddy/Caddyfile
chat.yourdomain.com {
    reverse_proxy localhost:8065
}
sudo systemctl restart caddy

Step 5: Initial Setup

  1. Open https://chat.yourdomain.com
  2. Create admin account
  3. Create your first team
  4. Configure System ConsoleEnvironment → verify settings

Step 6: Essential Configuration

System Console settings to configure:

SettingRecommendation
Site URLhttps://chat.yourdomain.com
Max file size100 MB
Enable plugins
Enable integrations
Session length720 hours (30 days)
Rate limitingEnable for production

Step 7: Install Plugins

PluginPurpose
CallsVoice/video calls (built-in)
PlaybooksIncident management
GitHubNotifications, PR reviews
JiraIssue tracking integration
GitLabMR notifications
ZoomMeeting integration
CalendarShared team calendar

Install via System ConsolePlugin Marketplace.

Step 8: Invite Team

  1. Main MenuInvite People
  2. Generate invite link or send email invitations
  3. Share desktop/mobile app download links:
    • Desktop: mattermost.com/apps
    • iOS: App Store
    • Android: Google Play

Production Hardening

Backups:

# Database backup (daily cron)
docker compose exec db pg_dump -U mmuser mattermost > /backups/mm-$(date +%Y%m%d).sql

# File attachments backup
tar czf /backups/mm-files-$(date +%Y%m%d).tar.gz ./volumes/app/mattermost/data

Updates:

cd mattermost-docker
docker compose pull
docker compose up -d

Monitoring:

  • Monitor port 8065 with Uptime Kuma
  • Set up disk space alerts (file attachments grow)
  • Monitor PostgreSQL connections

Resource Usage

UsersRAMCPUDisk
1-504 GB2 cores20 GB
50-1008 GB4 cores50 GB
100-50016 GB8 cores100 GB

VPS Recommendations

ProviderSpec (50 users)Price
Hetzner4 vCPU, 8 GB RAM€8/month
DigitalOcean2 vCPU, 4 GB RAM$24/month
Linode2 vCPU, 4 GB RAM$24/month

Compare team chat platforms on OSSAlt — features, self-hosting guides, and community health side by side.