How to Install Discourse Forum on VPS

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.

  1. 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.
  2. Connect to Your VPS

    • Once your VPS is created, connect to it using SSH:
       
      ssh username@your-vps-ip
  3. Update Your System

    • It’s always a good idea to update the system before proceeding with the installation:
       
      sudo apt update && sudo apt upgrade -y

Step 2: Install Dependencies

Discourse requires Docker and some other dependencies to run properly. Follow these steps to install them:

  1. Install Docker

    • Install Docker on your VPS by running the following commands:
       
      sudo apt install -y docker.io
  2. Install Docker Compose

    • Docker Compose is a tool used to manage multi-container Docker applications. To install Docker Compose:
       
      sudo apt install -y docker-compose
  3. Install Required Dependencies

    • Install any additional dependencies required for Discourse:
       
      sudo apt install -y git curl wget
  4. 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:

  1. Update DNS Records

    • Set up an A record pointing to your VPS's public IP address.
  2. 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.

  1. Clone the Discourse Repository

    • Navigate to your home directory and clone the Discourse Docker repository:
       
      cd /home/username git clone https://github.com/discourse/discourse_docker.git
  2. Navigate to the Discourse Docker Directory

    • Go to the cloned repository directory:
       
      cd discourse_docker
  3. Configure Discourse

    • Run the setup script to configure Discourse for your server:

       
      cp samples/standalone.yml containers/app.yml
    • Edit the app.yml configuration file:

       
      nano containers/app.yml
      • Set the hostname to your domain:
        yaml
         
        DISCOURSE_HOSTNAME: 'yourdomain.com'
      • 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:
        yaml
         
        DISCOURSE_SMTP_ADDRESS: smtp.mailgun.org DISCOURSE_SMTP_PORT: 587 DISCOURSE_SMTP_USER_NAME: [email protected] DISCOURSE_SMTP_PASSWORD: 'your-mailgun-password' DISCOURSE_SMTP_DOMAIN: mailgun.org
  4. Run the Discourse Setup

    • Once the configuration is done, you can build the Discourse Docker container and start it with:
       
      sudo ./launcher bootstrap app sudo ./launcher start app
  5. Allow Necessary Ports

    • Allow HTTP and HTTPS traffic in your server’s firewall:
       
      sudo ufw allow 80,443/tcp sudo ufw reload

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:

  1. Edit the Configuration File

    • Open the app.yml file again:
       
      nano containers/app.yml
  2. Enable SSL

    • Enable SSL by setting the DISCOURSE_SSL variable to true:
      yaml
       
      DISCOURSE_SSL: true
  3. Configure SSL Certificates

    • To use Let’s Encrypt for SSL certificates, add the following under your domain in app.yml:
      yaml
       
      LETSENCRYPT_ACCOUNT_EMAIL: '[email protected]'
  4. Rebuild the Discourse Container

    • After saving the changes, rebuild the Discourse container:
       
      sudo ./launcher rebuild app
  5. 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

  1. Access the Forum

    • Visit your forum at https://yourdomain.com in a web browser. You should see the Discourse setup page.
  2. 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.
  3. 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.
  4. 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:

 
cd /home/username/discourse_docker sudo ./launcher rebuild app

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.

Was this answer helpful? 0 Users Found This Useful (0 Votes)

Powered by WHMCompleteSolution