Install Discourse on Ubuntu 22.04

Today you will learn how to install Discourse on Ubuntu 22.04. Discourse is a free and open-source platform created for discussion forums, chat rooms and mailing lists for your team. Discourse is developed using Ember.js and Ruby on Rails, and uses PostgreSQL database.

Some of the cool features of Discourse are two-factor authentication, social login, spam blocking, single sign on, emojis, community moderation and mobile layout.

Install Discourse on Ubuntu 22.04

Prerequisites

  • A valid domain pointing to your server or localhost
  • An SMTP mail server
  • Root privileges
  • Docker installed

Install Docker on Ubuntu 22.04

Update the system packages

apt update

Install curl and git if not installed:

apt install curl git

Add Docker’s official GPG key:

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

Setup a stable repository:

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

Update the system packages again.

apt update

Now install the latest version of Docker.

apt install docker-ce docker-ce-cli containerd.io

You can check if docker is running:

$ systemctl status docker
● docker.service - Docker Application Container Engine
     Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
     Active: active (running) since Sun 2022-06-26 20:20:28 EAT; 1h 10min ago
TriggeredBy: ● docker.socket
       Docs: https://docs.docker.com
   Main PID: 4425 (dockerd)
      Tasks: 8
     Memory: 31.0M
        CPU: 4.160s
     CGroup: /system.slice/docker.service
             └─4425 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock

Jun 26 20:20:24 itnixpro dockerd[4425]: time="2022-06-26T20:20:24.021748107+03:00" level=info msg="scheme \"unix\" not registered, fallback t>
Jun 26 20:20:24 itnixpro dockerd[4425]: time="2022-06-26T20:20:24.021864717+03:00" level=info msg="ccResolverWrapper: sending update to cc: {>
Jun 26 20:20:24 itnixpro dockerd[4425]: time="2022-06-26T20:20:24.021941910+03:00" level=info msg="ClientConn switching balancer to \"pick_fi>
Jun 26 20:20:25 itnixpro dockerd[4425]: time="2022-06-26T20:20:25.100546260+03:00" level=info msg="Loading containers: start."
Jun 26 20:20:25 itnixpro dockerd[4425]: time="2022-06-26T20:20:25.886258413+03:00" level=info msg="Default bridge (docker0) is assigned with >
Jun 26 20:20:26 itnixpro dockerd[4425]: time="2022-06-26T20:20:26.404974167+03:00" level=info msg="Loading containers: done."
Jun 26 20:20:27 itnixpro dockerd[4425]: time="2022-06-26T20:20:27.576201918+03:00" level=info msg="Docker daemon" commit=a89b842 graphdriver(>
Jun 26 20:20:27 itnixpro dockerd[4425]: time="2022-06-26T20:20:27.589069813+03:00" level=info msg="Daemon has completed initialization"
Jun 26 20:20:28 itnixpro systemd[1]: Started Docker Application Container Engine.
Jun 26 20:20:28 itnixpro dockerd[4425]: time="2022-06-26T20:20:28.202954251+03:00" level=info msg="API listen on /run/docker.sock"
lines 1-22/22 (END)

Install Discourse on Ubuntu 22.04

You will install Discourse using git. So create a folder to store Discourse files.

mkdir -p /var/discourse/

Clone the discourse repository with the command below:

git clone https://github.com/discourse/discourse_docker.git /var/discourse/

Move to the directory created

cd /var/discourse/ 

Copy the sample configuration file:

cp samples/standalone.yml containers/app.yml

Now edit the file above:

nano containers/app.yml

Find and edit DISCOURSE_HOSTNAME and DISCOURSE_DEVELOPER_EMAILS with the correct values.

Then setup SMTP details. Uncomment the lines below and replacing them with the correct values to look like:

DISCOURSE_SMTP_ADDRESS: smtp.gmail.com
DISCOURSE_SMTP_PORT: 587
DISCOURSE_SMTP_USER_NAME: [email protected]
DISCOURSE_SMTP_PASSWORD: ITn1xPr0@2O22
DISCOURSE_SMTP_ENABLE_START_TLS: true

To setup Let’s Encrypt, uncomment the line: LETSENCRYPT_ACCOUNT_EMAIL and enter the email to be used to generate certificates. I will leave this blank because I will be setting up discourse locally.

I have also commented out the https line to look as below because I’m not using secure connection. This is not necessary though.

expose:
    - "80:80" #http
#  - "443:443" #https

Next, bootstrap the app.

./launcher bootstrap app

Now start the app

./launcher start app

In case you want to make modifications, you can edit the file /var/discourse/containers/app.yml then run ./launcher rebuild app to apply the changes.

Access Discourse Web Interface

Open your web browser and enter the URL for your hostname i.e. http://discourse.itnixpro.com. You will be redirected to register an admin account.

Install Discourse on Ubuntu 22.04
Register

Click on Register and enter the admin account details.

Install Discourse on Ubuntu 22.04
Register an admin account

Check you email and follow the instructions to activate your account

Install Discourse on Ubuntu 22.04
Confirm your email

Discourse is successfully installed. Continue to set up a few things.

Upgrade Discourse

In case you want to upgrade Discourse after installation, first move to Discourse directory

cd /var/discourse/

Pull the latest version and rebuild the app

git pull
./launcher rebuild app

How to uninstall Discourse from Ubuntu 22.04

First check the container ID by running the command:

docker ps
CONTAINER ID   IMAGE                 COMMAND        CREATED          STATUS          PORTS                                                                      NAMES
6bbae468c171   local_discourse/app   "/sbin/boot"   53 minutes ago   Up 53 minutes   0.0.0.0:80->80/tcp, :::80->80/tcp, 0.0.0.0:443->443/tcp, :::443->443/tcp   app

Next, stop the container using the ID obtained above: Docker stop container ID. In this case;

docker stop container 6bbae468c171

Now delete the container using the same ID

docker container rm CONTAINER 6bbae468c171

Conclusion

This demo showed you how to install Discourse on Ubuntu 22.04. You did some configurations and now you are set to use Discourse. Enjoy communication using discourse.

More features and how to integrate with other services can be found in Discourse official website.

Similar interesting tutorials

Install Mattermost on Ubuntu 22.04

Install Slack on Ubuntu 22.04

Install Telegram Desktop App on Ubuntu 22.04

Android Developer | Linux | Technical Writer | Backend Developer

Leave a Comment