Knowledgebase

How to Install Discourse on Ubuntu 20.04 Print

  • 0

Introduction

Discourse is a modern, open-source discussion and forum system. This article describes how to set up Discourse with a free SSL Certificate from Let's Encrypt on Ubuntu 20.04.

Prerequisites

Before you begin with the Discourse installation:

  • Deploy a new Ubuntu 20.04 cloud server with at least 2 GB of RAM.
  • Set up an SMTP server for Discourse emails. You can register for a transactional email account from external email providers such as Mailgun or Sendgrid. Discourse has a list of recommended email providers.
  • You'll need a fully-qualified domain name (FQDN) such as discourse.example.com to create an SSL certificate with Let's Encrypt.

    Create an FQDN at your DNS provider and point the name to the IP address of your server instance. It may take some time for the name to propagate through the DNS system. Use a DNS checking site to ensure the name has fully propagated before proceeding.

1. Secure the Server

  1. Turn on automatic security updates.

    $ sudo dpkg-reconfigure -plow unattended-upgrades
    
  2. Setup a firewall with ufw.

    $ sudo apt-get install ufw
    $ sudo ufw default allow outgoing
    $ sudo ufw default deny incoming
    $ sudo ufw allow 22 comment 'SSH'
    $ sudo ufw allow http comment 'HTTP'
    $ sudo ufw allow https comment 'HTTPS'
    $ sudo ufw enable
    
  3. Install fail2ban to secure your server

    $ sudo apt install fail2ban
    

Configure fail2ban to Use ufw

  1. Copy the main configuration to avoid unexpected changes during package updates.

    $ sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local
    
  2. Edit the configuration file with your favorite text editor

    $ sudo nano /etc/fail2ban/jail.local
    
  3. Change the banaction and banaction_allports settings to ufw in the file /etc/fail2ban/jail.local as follows:

    banaction = ufw
    banaction_allports = ufw
    

2. Collect the SMTP Details

Next, you'll need to collect the SMTP details from your transactional email account.

You need the following information:

  • SMTP server address
  • SMTP port
  • SMTP user name
  • SMTP password

3. Access Your Rcs VPS

Connect to your server instance with SSH. For example, if your server's IP address is 192.0.2.123:

$ ssh root@192.0.2.123

4. Install Docker

Docker is an open-source platform for developing, shipping, and running applications. Docker enables you to run Discourse in an isolated and optimized environment. Use these steps to install Docker on your server.

  1. Uninstall old versions such as docker, docker.io, or docker-engine.

    $ sudo apt-get remove docker docker-engine docker.io containerd runc
    
  2. Set up the repository.

    $ sudo apt-get update
    $ sudo apt-get install ca-certificates curl gnupg lsb-release
    $ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
    $ echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
    $ sudo apt update
    
  3. Install the latest version of Docker Engine.

    $ sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin
    

5. Install Discourse

  1. Create a 'discourse' folder in the /var directory.

    $ mkdir /var/discourse
    
  2. Clone the official Discourse git repository in /var/discourse.

    $ git clone https://github.com/discourse/discourse_docker.git /var/discourse
    
  3. Change to the Discourse directory.

    $ cd /var/discourse
    
  4. Launch the setup tool.

    $ ./discourse-setup
    
  5. Answer the prompted questions with your hostname and SMTP details. The Discourse setup script may ask the following questions:

    • Hostname for your Discourse?: Enter your chosen hostname for your Discourse platform (for example, discourse.example.com).
    • Email address for admin account(s)?: Choose the email address for your Discourse admin account. It can be any email address. When setting up the Discourse control panel, you need to reuse this email address.
    • SMTP server address?: Enter your SMTP server address. For example, the SMTP server address for Sendgrid is smtp.sendgrid.net
    • SMTP port?: Enter your SMTP port. For example, the SMTP port is 587.
    • SMTP user name?: Enter your SMTP user name. For example, Mailgun provides you with a user name. For Sendgrid, you must set the user name precisely to the string apikey.
    • SMTP password?: Enter your SMTP user password. For example, Mailgun provides you with a password. For Sendgrid, you can enter your generated API key.
  6. Press ENTER to confirm your settings, and the installation process begins automatically. The setup tool requests a Let's Encrypt SSL certificate by default.

You can run ./discourse-setup again if you need to change these settings.

6. Start Discourse

To access your Discourse instance, use a web browser to navigate to your domain name, then follow the setup wizard to register your admin account.

7. Upgrade Discourse

Visit https://your_hostname/admin/upgrade, then click Upgrade to the Latest Version and follow the instructions.

Or, you can upgrade Discourse from the command line as follows:

  1. Change directory to /var/discourse

    $ cd /var/discourse
    
  2. Get the latest version of Discourse

    $ sudo git pull
    
  3. Rebuild the Discourse app

    $ sudo ./launcher rebuild app
    

More Information


Was this answer helpful?
Back

Powered by WHMCompleteSolution