Discourse is an open-source forum platform built for modern web usage. It offers a clean and responsive design, real-time notifications, powerful moderation tools, and a highly customizable environment. Setting up Discourse on your VPS is straightforward if you follow the steps outlined below. In this guide, we will walk you through the entire installation process, including setting up your VPS, installing necessary dependencies, and configuring Discourse for your community.
Step 1: Set Up Your VPS
Before you can install Discourse, you need to prepare your VPS. You can use any reputable VPS provider like DigitalOcean, Linode, Vultr, or AnonVM.
-
Create a VPS
- Choose a server with at least 1GB of RAM (2GB or more is recommended for better performance).
- Install Ubuntu 20.04 LTS or later as your operating system. You can also use other Linux distributions, but Ubuntu is recommended.
-
Connect to Your VPS
- Once your VPS is created, connect to it using SSH:
-
Update Your System
- It’s always a good idea to update the system before proceeding with the installation:
Step 2: Install Dependencies
Discourse requires Docker and some other dependencies to run properly. Follow these steps to install them:
-
Install Docker
- Install Docker on your VPS by running the following commands:
-
Install Docker Compose
- Docker Compose is a tool used to manage multi-container Docker applications. To install Docker Compose:
-
Install Required Dependencies
- Install any additional dependencies required for Discourse:
-
Install Required Libraries
- Discourse requires PostgreSQL and Redis, which are installed automatically when using Docker, but make sure you have the correct versions of these services in place.
Step 3: Set Up a Domain Name
Discourse requires a domain name to run properly. If you don’t already have a domain, you can purchase one from a domain provider like Namecheap or GoDaddy. Once you have a domain, point it to your VPS IP address:
-
Update DNS Records
- Set up an A record pointing to your VPS's public IP address.
-
Set Up SSL (Optional, but Recommended)
- You can use Let’s Encrypt to get a free SSL certificate for your domain. We will configure this in the next steps.
Step 4: Install Discourse Using Docker
Discourse provides an official Docker-based installation method. This is the easiest way to install Discourse on your server.
-
Clone the Discourse Repository
- Navigate to your home directory and clone the Discourse Docker repository:
-
Navigate to the Discourse Docker Directory
- Go to the cloned repository directory:
-
Configure Discourse
-
Run the setup script to configure Discourse for your server:
-
Edit the
app.yml
configuration file:- Set the hostname to your domain:
- Set your email and SMTP configuration (you can use services like Mailgun or SendGrid for email delivery).
- Ensure the following configuration is set to match your setup:
-
-
Run the Discourse Setup
- Once the configuration is done, you can build the Discourse Docker container and start it with:
-
Allow Necessary Ports
- Allow HTTP and HTTPS traffic in your server’s firewall:
Step 5: Set Up SSL with Let’s Encrypt
Now that Discourse is installed, it's time to secure your site using Let’s Encrypt for SSL:
-
Edit the Configuration File
- Open the
app.yml
file again:
- Open the
-
Enable SSL
- Enable SSL by setting the
DISCOURSE_SSL
variable totrue
:
- Enable SSL by setting the
-
Configure SSL Certificates
- To use Let’s Encrypt for SSL certificates, add the following under your domain in
app.yml
:
- To use Let’s Encrypt for SSL certificates, add the following under your domain in
-
Rebuild the Discourse Container
- After saving the changes, rebuild the Discourse container:
-
Check SSL
- After rebuilding, Discourse will automatically obtain and install an SSL certificate from Let’s Encrypt. Your forum should now be accessible over HTTPS.
Step 6: Finalizing Your Discourse Installation
-
Access the Forum
- Visit your forum at
https://yourdomain.com
in a web browser. You should see the Discourse setup page.
- Visit your forum at
-
Complete the Setup
- Follow the on-screen instructions to complete the setup. You’ll need to:
- Create an admin account.
- Configure basic settings like categories, user permissions, and theme.
- Follow the on-screen instructions to complete the setup. You’ll need to:
-
Set Up Additional Features
- You can add plugins to your Discourse forum, such as for enhancing search functionality, adding social login, or setting up additional moderation tools. Visit the Discourse Plugin Directory to browse available plugins.
-
Set Up Backups
- It’s important to configure automatic backups of your Discourse instance to ensure you don’t lose any data. You can configure this through the Admin Dashboard.
Step 7: Keep Discourse Updated
Discourse releases frequent updates to improve features and security. To keep your Discourse forum up to date, periodically run the following command:
This will pull the latest updates and rebuild the Discourse container.
Conclusion
You have now successfully installed and configured Discourse on your VPS. Discourse offers a great platform for building communities with a modern design and excellent performance. By following this guide, you’ve set up a secure, scalable, and feature-rich forum for your users.
If you want to customize your forum further, explore the many themes, plugins, and settings available in the Discourse Admin Panel.