Author: Quan HuaLast Updated: Thu, Jun 9, 2022
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.
Before you begin with the Discourse installation:
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.
Turn on automatic security updates.
$ sudo dpkg-reconfigure -plow unattended-upgrades
Setup a firewall with
$ 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
fail2ban to secure your server
$ sudo apt install fail2ban
Copy the main configuration to avoid unexpected changes during package updates.
$ sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local
Edit the configuration file with your favorite text editor
$ sudo nano /etc/fail2ban/jail.local
banaction_allports settings to
ufw in the file
/etc/fail2ban/jail.local as follows:
banaction = ufw banaction_allports = ufw
Next, you'll need to collect the SMTP details from your transactional email account.
You need the following information:
Connect to your server instance with SSH. For example, if your server's IP address is
$ ssh email@example.com
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.
Uninstall old versions such as
$ sudo apt-get remove docker docker-engine docker.io containerd runc
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
Install the latest version of Docker Engine.
$ sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin
Create a 'discourse' folder in the
$ mkdir /var/discourse
Clone the official Discourse git repository in
$ git clone https://github.com/discourse/discourse_docker.git /var/discourse
Change to the Discourse directory.
$ cd /var/discourse
Launch the setup tool.
Answer the prompted questions with your hostname and SMTP details. The Discourse setup script may ask the following questions:
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.
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.
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:
Change directory to
$ cd /var/discourse
Get the latest version of Discourse
$ sudo git pull
Rebuild the Discourse app
$ sudo ./launcher rebuild app