Discourse – Install it simple

 
Discourse – Install it simple

What is Discourse?

  • The powerful, open platform for communities of all kinds.
  • Discourse is build for discussion and connection.
  • Keep your forum on brand, integrate with your tech stack, and optimize forum features for engagement.
  • An integrated experience for chat and long form discussions enables members to build relationships while your community builds knowledge.
  • Keep the discussion healthy and on-track with our best-in-class moderation tools.

**Notes: The only officially supported installs of Discourse are Docker based. You must have SSH access to a 64-bit Linux server with Docker support.
It regrets that it cannot support any other methods of installation including cpanel, plesk, webmin, etc.
With Docker, their fully optimized Discourse configuration is available to us in a simple container.

Operating System Requirements:

You must have SSH access to a 64-bit Linux server with Docker support. I personally suggest Ubuntu Latest version.

Hardware Requirements:

  • Modern single core CPU, dual core recommended
  • 1 GB RAM minimum (with swap)
  • 64 bit Linux compatible with Docker
  • 10 GB disk space minimum

Software Requirements:

  • Postgres 13
  • Redis 7
  • Ruby 3.2+

Let us see install steps of all softwares and disourse community.
Here it is required to login to SSH because installation will be handled by ssh commands.

Postgres Install Commands:

Step 1: # Create the file repository configuration:

sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'

Step 2: # Import the repository signing key:

wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -

Step 3: # Update the package lists:

sudo apt-get update

Step 4: # Install the latest version of PostgreSQL. If you want a specific version, use ‘postgresql-12’ or similar instead of ‘postgresql’:

sudo apt-get -y install postgresql-13

Redis Install Commands:

Step 1: # Verify System Parameter

sudo ufw allow OpenSSH
sudo ufw enable
sudo ufw status

Step 2: # Install Redis

sudo add-apt-repository ppa:redislabs/redis
sudo apt update
sudo apt install redis-server

Step 3: # Enable and Run Redis

sudo vi /etc/redis/redis.conf

– change “supervised” value into “systemd“, ie “supervised systemd

sudo systemctl restart redis.service

– (if this command fails, use: “sudo systemctl unmask redis-server.service“)

To check client, run: sudo redis-cli
It will enter into prompt, enter: PING, then it will reply as PONG. If so, it is installed successfully

Ruby on Rails Install Commands:

sudo apt update
sudo apt install ruby-full
sudo ruby --version 

– (output: ruby 3.0.2p107)

Docker Install Commands:

sudo apt update
sudo apt upgrade -y
sudo wget -qO- https://get.docker.com/ | sh
sudo docker version
sudo systemctl status  docker

Discourse Install Commands:

sudo mkdir /var/discourse
sudo git clone https://github.com/discourse/discourse_docker.git /var/discourse
sudo su -

(“sudo su -” : This command enters into root mode)

cd /var/discourse
./discourse-setup
– While setting up, it will ask for domain name(ie website in which discourse will be setup, Ex: test.myforum.com), admin email address, smtp details.
– So before start “./discourse-setup” command, make sure domain name/email/smtp are available and active.
– Setup will be run for few minutes, once setup done, the discouse community forum website is ready.
– Now access your domain url in the browser, then it will allow to setup Backend user.
– Once backend user details given(like user name/password), it will send activation email to admin email address we have given in the setup
– Activate the activation link in the email. Then it is ready to login to backend and post forums.
– Thats all. Fun with Forum.

Rebuild Discourse:

In case of changing website name or admin email address or smtp details or any new plugin installs in discourse forum, it is very easy to do changes.
To do, it is required to modify “app.yml” config file.
That app.yml config file is located in the path: /var/discourse/containers
Download the app.yml file into local system, and do modify the following settings:

  • To change domain name: DISCOURSE_HOSTNAME
  • To change admin email: DISCOURSE_DEVELOPER_EMAILS
  • To change smtp settings: DISCOURSE_SMTP_ADDRESS, DISCOURSE_SMTP_PORT, DISCOURSE_SMTP_USER_NAME, DISCOURSE_SMTP_PASSWORD
  • To add or remove plugins: modify in the “hooks” section

After modification completed in the app.yml config file, upload it in the server.
Before upload, take backup the current app.yml in server( or in your local system), then upload the modified version

To reflect the changes in the website, we need to rebuild the discourse community, like intial setup.
Following commands will help to rebuild the discourse community.

cd /var/discourse
sudo ./launcher rebuild app

Migrate discourse forum data from one server to another server:

In some cases, we need to migrate discourse community forum from one hosting server to another.
It is very simple to achive this by following the below steps.

  • Connect to Old server FTP, and goto the path: /var/discourse/shared/standalone/backups
  • Download the latest backup file.
  • Connect to New server FTP, and goto the path: /var/discourse/shared/standalone/backups/default
  • Upload the downloaded backup file from old server.
  • Login to New server website backend.
  • Go to: Admin > Preferences > Backups: Enable Restore option. (Then only we can restore any backup file).
  • Go to: Admin > Backups tab, and verify that uploaded Backup file is listed. Then click Restore button to restore the backup.
  • Admin > Backups tab > Log tab will show the restore running as logs.
  • After restore finished, it will automatically logout of it.
  • After refreshed, Then we can see Old server templates with posts in the new server website.
  • To make sure, login with New server admin login details.
  • That’s it.

**Note: Latest discourse has backup in the following path: “/var/discourse/shared/standalone/backups/default“.
So before migrate, make sure the correct backup path in both old and new servers.

Reference Websites:

Thank you.
Enjoy the coding!!!

Muneeswaran
Latest posts by Muneeswaran (see all)