How to Self-Host Discourse on a VPS (Complete Guide)
Discourse is a powerful open-source discussion platform designed for communities and organizations. Self-hosting Discourse on a VPS gives you greater control and flexibility. This guide walks you through the steps to install Discourse on a VPS using Docker, covering the prerequisites, configuration, and troubleshooting tips.
Choosing the Right VPS Provider
Before you can self host Discourse, you need to choose a suitable VPS provider. Below is a comparison of some popular VPS providers:
| Provider | Price (EUR/USD) | Key Features |
|---|---|---|
| Contabo VPS | 5.99 EUR/mo | High disk space, SSD, scalable resources |
| Hetzner Cloud | 4.15 EUR/mo | Affordable pricing, good performance |
| DigitalOcean | 6 USD/mo | Simple management interface, robust APIs |
| Vultr | 6 USD/mo | Fast deployment, global low-latency data centers |
| Linode (Akamai) | 5 USD/mo | Reliable service, good education resources |
You can find a more detailed comparison on our full VPS comparison.
Prerequisites
- Choose a VPS Plan: For this guide, a minimal setup with at least 2GB of RAM is recommended for optimal performance.
- Operating System: Ubuntu 20.04 or later is preferred.
- Domain Name: Set up a domain name pointing to your VPS IP address to make access easier.
- Access to the VPS: SSH access to your server is necessary.
Installing Docker and Docker Compose
Discourse runs on Docker, so you need to install it first. Follow these steps:
-
SSH into your VPS:
ssh root@your_vps_ip -
Update the package list:
sudo apt update -
Install Docker:
sudo apt install docker.io -
Enable Docker:
sudo systemctl enable docker sudo systemctl start docker -
Install Docker Compose:
sudo apt install docker-compose
Installing Discourse
With Docker and Docker Compose installed, you can now set up Discourse:
-
Set Up the Discourse Directory:
sudo mkdir /var/discourse cd /var/discourse -
Clone the Discourse GitHub Repository:
sudo git clone https://github.com/discourse/discourse_docker.git . -
Run the Setup Script:
sudo ./discourse-setupThe script will prompt you for features such as email address and domain name. Ensure to enter your domain correctly.
-
Configure Email Settings: If you plan to use a SMTP server, follow the prompts to configure it. You can use services like SendGrid or Mailgun for sending emails.
Starting Discourse
Once the setup is complete, you can start Discourse:
sudo ./launcher bootstrap app
sudo ./launcher start app
Accessing Your Discourse Instance
Open your browser and navigate to http://yourdomain.com. You should be greeted with the Discourse setup screen, where you can create your admin account and start configuring your forum.
FAQs
1. What VPS specifications are recommended for self-hosting Discourse?
For optimal performance, it is recommended to use a VPS with at least 2GB of RAM and a modern multi-core CPU. Discourse can be quite resource-intensive, especially with multiple users. Additionally, consider SSD storage for faster data access. If you expect significant traffic, upgrading to a VPS with more resources might be necessary. Providers like Hetzner or Contabo often provide good value for the needed specifications.
2. What should I do if I encounter issues during installation?
Common issues during Discourse installation include network connectivity problems, incorrect domain settings, or issues with Docker. First, check your serverโs firewall settings to ensure that necessary ports (like 80 and 443) are open. Also, examine the logs with:
sudo ./launcher logs app
This provides detailed information on what might be failing. Consult the Discourse Meta community for support if youโre still stuck.
3. How can I secure my Discourse instance?
To secure your Discourse installation, you should configure HTTPS. You can use Letโs Encrypt to obtain a free SSL certificate, which is essential for encrypting data transmission. During the Discourse setup, you should have provided your email and domain; the setup script automatically configures Letโs Encrypt for you. Additionally, always keep your Discourse instance updated, as updates often include important security patches.
With this guide, you should have a fully functional Discourse instance on your VPS. For further enhancements and self-hosting tools, consider exploring resources on r/selfhosted or the awesome-selfhosted list. Happy self-hosting!