Technology Encyclopedia Home >How to Deploy Discourse Forum on a Cloud Server — A Production-Ready Community Platform

How to Deploy Discourse Forum on a Cloud Server — A Production-Ready Community Platform

I needed to set up a community forum for a project and looked at a lot of options. Most self-hosted forum software feels like it was designed in 2005. Discourse feels current: clean interface, real-time updates, good mobile experience, sensible moderation tools.

The trade-off with Discourse is that the official installation uses Docker and requires at least 2 GB RAM. It's not the most lightweight thing to self-host. But for a community that outgrows simple chat or comment sections, it's the right tool for the job.

The email configuration is the one thing you absolutely have to get right before going live — Discourse is heavily dependent on email for account creation and notifications. This guide covers that explicitly, along with the Docker-based installation that the Discourse team officially supports.

I run Discourse on Tencent Cloud Lighthouse. Discourse requires at minimum 2 GB RAM — 4 GB is more comfortable for a small-to-medium community. As your community grows, Lighthouse's spec upgrade option lets you move to a higher-RAM plan without re-deploying or migrating data. The snapshot feature is particularly valuable before Discourse version upgrades (which the official launcher handles, but aren't always smooth) — a pre-upgrade snapshot means you can restore in minutes if the update causes issues.


Table of Contents

  1. What Discourse Provides
  2. Prerequisites
  3. Part 1 — Server Setup
  4. Part 2 — Install Docker
  5. Part 3 — Clone and Configure Discourse
  6. Part 4 — Configure Email (Required)
  7. Part 5 — Build and Start Discourse
  8. Part 6 — Complete Setup in the Browser
  9. Part 7 — Post-Installation Configuration
  10. Part 8 — Backups
  11. The Gotcha: Email Configuration Is Not Optional
  12. Admin Commands Reference

  • Key Takeaways
  • Use the appropriate Lighthouse application image to skip manual installation steps where available
  • Lighthouse snapshots provide one-click full-server backup before major changes
  • OrcaTerm browser terminal lets you manage the server from any device
  • CBS cloud disk expansion handles growing storage needs without server migration
  • Console-level firewall + UFW = two independent protection layers

What Discourse Provides {#what}

Feature What it does
Discussion categories Organized topic areas
Trust levels Progressive user permissions (new → regular → leader → moderator)
Full-text search Built-in search across all posts
Email notifications Digest emails, mention notifications
SSO Single sign-on with other systems
Plugins Hundreds of community-built plugins
Chat Built-in real-time messaging (optional)
Polls Native polling in topics
API Full REST API for integrations

Prerequisites {#prerequisites}

Requirement Notes
Cloud server Tencent Cloud Lighthouse Ubuntu 22.04
2 GB RAM minimum 4 GB recommended for comfortable performance
20 GB+ disk Discourse uses ~2 GB for the base installation; grows with content
A domain name Required — Discourse needs a domain, not just an IP
Email service Mandatory for Discourse to function (Mailgun, SendGrid, or SMTP)

Part 1 — Server Setup {#part-1}

ssh ubuntu@YOUR_SERVER_IP
sudo apt update && sudo apt upgrade -y

# Discourse's official installer requires these
sudo apt install -y git wget

# Open firewall
sudo ufw allow ssh
sudo ufw allow http
sudo ufw allow https
sudo ufw enable

Part 2 — Install Docker {#part-2}

Discourse's official installer is Docker-based. Install Docker first:

curl -fsSL https://get.docker.com | sudo sh
sudo usermod -aG docker $USER
newgrp docker

# Verify
docker --version

Part 3 — Clone and Configure Discourse {#part-3}

Discourse has an official Docker-based deployment tool called discourse_docker:

sudo git clone https://github.com/discourse/discourse_docker.git /var/discourse
cd /var/discourse
sudo cp samples/standalone.yml containers/app.yml
sudo nano containers/app.yml

The key sections to configure:

## Hostname for your Discourse instance
DISCOURSE_HOSTNAME: 'forum.yourdomain.com'

## Required: developer emails (get admin access on first login)
DISCOURSE_DEVELOPER_EMAILS: 'you@yourdomain.com'

## Email configuration (see Part 4)
DISCOURSE_SMTP_ADDRESS: smtp.mailgun.org
DISCOURSE_SMTP_PORT: 587
DISCOURSE_SMTP_USER_NAME: postmaster@mg.yourdomain.com
DISCOURSE_SMTP_PASSWORD: your_mailgun_password
DISCOURSE_SMTP_ENABLE_START_TLS: true

## Contact email shown on the site
DISCOURSE_NOTIFICATION_EMAIL: noreply@yourdomain.com

## CDN (optional, improve global performance)
# DISCOURSE_CDN_URL: https://your-cdn.example.com

Part 4 — Configure Email (Required) {#part-4}

Discourse requires email for user registration, notifications, and admin setup. You must configure an SMTP service before installation.

Option A: Mailgun (recommended for reliability)

  1. Sign up at mailgun.com
  2. Add your domain and verify DNS records
  3. Get SMTP credentials:
    • SMTP hostname: smtp.mailgun.org
    • Port: 587
    • Username: postmaster@mg.yourdomain.com
    • Password: from Mailgun dashboard

Option B: SendGrid

  1. Sign up at sendgrid.com
  2. Create an API key with Mail Send permission
  3. SMTP settings:
    • Server: smtp.sendgrid.net
    • Port: 587
    • Username: apikey
    • Password: your SendGrid API key

Update containers/app.yml with these credentials before proceeding.


Part 5 — Build and Start Discourse {#part-5}

cd /var/discourse

# Build the Discourse container (takes 10-30 minutes)
sudo ./launcher bootstrap app

This command:

  1. Downloads the Discourse Docker image
  2. Installs all dependencies
  3. Runs database migrations
  4. Compiles assets

Wait for it to complete. You'll see significant output — this is normal.

# Start Discourse
sudo ./launcher start app

# Check status
sudo ./launcher logs app

Visit http://forum.yourdomain.com — Discourse should load.


Part 6 — Complete Setup in the Browser {#part-6}

  1. Visit http://forum.yourdomain.com
  2. Click Register and use the email address you set as DISCOURSE_DEVELOPER_EMAILS
  3. Check your email for the confirmation link
  4. Confirm your account — you'll automatically have admin access
  5. The Setup Wizard will appear:
    • Set community title and description
    • Choose the primary language
    • Select site categories (e.g., General, Support, Announcements)
    • Configure trust levels
    • Choose a color scheme
    • Set up a welcome topic

Complete the wizard to finish initial setup.


Part 7 — Post-Installation Configuration {#part-7}

Enable HTTPS with Let's Encrypt

Discourse can handle its own SSL via containers/app.yml:

## Uncomment and configure:
- exec:
    cd: $home
    cmd:
      - ruby -e "require 'yaml'; y = YAML.load(File.read('config/discourse.conf')); y['force_https'] = true; File.open('config/discourse.conf', 'w') {|f| f.write(y.to_yaml)}"

Or use the standard Certbot + Nginx approach. Rebuild after any config change:

sudo ./launcher rebuild app

Key admin settings

Access via Admin → Settings:

Setting Recommendation
min_post_length 20 characters (prevents very short posts)
title_min_entropy 10 (prevents low-quality titles)
allow_new_registrations Enable or disable based on your community goals
default_locale Set to your community's primary language
max_image_size_kb 10240 (10 MB max image upload)

Install plugins

Edit containers/app.yml to add plugins before ./launcher rebuild app:

hooks:
  after_code:
    - exec:
        cd: $home/plugins
        cmd:
          - git clone https://github.com/discourse/discourse-math.git
          - git clone https://github.com/discourse/discourse-solved.git
          - git clone https://github.com/discourse/discourse-reactions.git

Then rebuild: sudo ./launcher rebuild app


Part 8 — Backups {#part-8}

Automated backups via Discourse admin

  1. Admin → Backups → Settings
  2. Enable: Create Backup Every N Days = 1
  3. Configure upload to S3/Google Drive for offsite storage

Manual backup

cd /var/discourse
sudo ./launcher enter app

# Inside the container
discourse backup
# Backup file appears in /var/www/discourse/public/backups/

exit

Restore

sudo ./launcher enter app
# Upload backup file to /var/www/discourse/public/backups/
discourse restore backup-file.tar.gz
exit

The Gotcha: Email Configuration Is Not Optional {#gotcha}

Discourse will appear to install correctly, but without working email:

  • New users can't confirm their accounts
  • Admin setup wizard may get stuck
  • Password resets don't work
  • Notification emails never arrive

The result: a forum that looks functional but can't onboard users.

Configure email before building the container. If you need to change email settings after installation:

  1. Edit containers/app.yml
  2. Rebuild: sudo ./launcher rebuild app
  3. Test email from Admin → Email → Send Test Email

For testing before going live, Mailtrap (mailtrap.io) provides a sandbox SMTP endpoint that catches all emails without actually sending them.


Admin Commands Reference {#commands}

# Discourse launcher commands
cd /var/discourse

sudo ./launcher start app           # Start Discourse
sudo ./launcher stop app            # Stop Discourse
sudo ./launcher restart app         # Restart
sudo ./launcher rebuild app         # Rebuild container (after config changes)
sudo ./launcher bootstrap app       # Full reinstall
sudo ./launcher logs app            # View logs
sudo ./launcher logs app -f         # Follow logs
sudo ./launcher enter app           # Shell inside container

# Inside the container (after ./launcher enter app):
discourse version                   # Check Discourse version
discourse upgrade                   # Upgrade to latest
rails runner "User.count"          # Quick data queries

# Update Discourse
sudo ./launcher rebuild app

Troubleshooting {#troubleshooting}

Issue Likely Cause Fix
Connection refused Service not running or wrong port Check systemctl status SERVICE and verify firewall rules
Permission denied Wrong file ownership or permissions Check file ownership with ls -la and use chown/chmod to fix
502 Bad Gateway Backend service not running Restart the backend service; check logs with journalctl -u SERVICE
SSL certificate error Certificate expired or domain mismatch Run sudo certbot renew and verify domain DNS points to server IP
Service not starting Config error or missing dependency Check logs with journalctl -u SERVICE -n 50 for specific error
Out of disk space Logs or data accumulation Run df -h to identify usage; clean logs or attach CBS storage
High memory usage Too many processes or memory leak Check with htop; consider upgrading instance plan if consistently high
Firewall blocking traffic Port not open in UFW or Lighthouse console Open port in Lighthouse console firewall AND sudo ufw allow PORT

Frequently Asked Questions {#faq}

How long does it take to set up Discourse on a cloud server?
With the appropriate Lighthouse application image (if available), setup takes 10–30 minutes. Manual installation from a plain Ubuntu image typically takes 30–90 minutes following this guide.

What server specifications do I need for Discourse?
Check the prerequisites section of this guide for specific requirements. As a general rule: start with the minimum recommended spec, monitor actual usage, and upgrade from the Lighthouse console if needed.

How do I keep Discourse updated?
Follow the update procedure specific to how it was installed (package manager, Docker pull, or binary replacement). Take a Lighthouse snapshot before any major update as a safety net.

How do I back up Discourse data?
Use Lighthouse snapshots for full-server recovery plus the application's own export/backup mechanism for granular recovery. Both together provide comprehensive backup coverage.

Can I run Discourse alongside other services on the same server?
Yes, with sufficient resources. Docker-based setups provide good isolation. Monitor resource usage with htop and expand the server spec or attach CBS storage as needed.

Build your community today:
👉 Tencent Cloud Lighthouse — Powerful VPS for Discourse
👉 View current pricing and promotions
👉 Explore all active deals and offers