Discourse – Bringing civilized discussion to the Internet
Being Civil
The open source Discourse framework modernizes bulletin boards and online forums with live updates as you read, providing never-ending scrolling, community moderation capabilities, heuristic spam blocking, special layouts for mobile devices, and more.
Let's face it: Internet forums have not improved much since the heyday of Usenet in the early 1990s, and when web-based forums came along, things got worse, not better. Say goodbye to threaded discussions, killfiles, cross-posting, uuencoded binary attachments, and many other wonderful features that had worked their way into the newsgroup-based technology over the years. Now, say hello to pages and pages of unstructured lists of messages, clunky interfaces, and endless, unreadable, unwrapped lines of text. All because, you know, the web.
Now Jeff Atwood (of Coding Horror and Stack Overflow fame), Robin Ward, Sam Saffron, Neil Lalonde, and Régis Hanol have decided to change all that. Meet Discourse [1], a framework that drags forums kicking and screaming into the 21st century.
With an interface (Figure 1) slightly reminiscent of the defunct Google Wave (now Apache Wave – equally more or less defunct), Discourse has the lofty goal of bringing civilized discussion to the Internet.
The list of features is impressive and includes live updates as you read, threads, never-ending scrolling (no more pages), community moderation capabilities, heuristic spam blocking, and special layouts for mobile devices, among many other features.
Although you can host your forum at the Discourse website (many options, plans, and prices are available, including having the team install the software for you on a server in the cloud), you can also set up your own forum on your own server. Discourse is distributed under the free GPL license after all, and uses exclusively free software on the back end.
That said, from download to a fully functional Discourse site is quite a bumpy ride. Multiple dependencies have to be resolved, installed, and configured in obscure ways, and the documentation is not all that up to date. Because this method of deploying Discourse is unsupported (the developers would prefer you used a Docker container in the cloud), you might consider using the methods recommended by the creators; they are very reasonable.
Being as hardheaded as I am, though, I gave it a shot, and here's how I fared.
Pre-Installation
As usual, I start with a stock Debian (wheezy server) install, updated and upgraded:
apt-get update apt-get upgrade
The instructions for installing on Ubuntu or any other Debian-based distro can be found at the Discourse GitHub site [3]. The distro is labeled deprecated by the developers, and some of the instructions are not relevant or have changed since it was written, but it is a good start. Be patient because the preinstall is a looong and rather convoluted process; however, trust me, it pays off in the end.
First, get the dependencies out of the way by installing git
and vim
– Git to download the Discourse software tree, and vim because it is always useful:
# apt-get install git vim
Next, get rid of Apache completely to avoid port collisions (Discourse prefers Nginx),
# apt-get purge apache2.2-common
and install Nginx as the web server and PostgreSQL as the database back end:
# apt-get install postgresql postgresql-contrib-9.1 nginx
The tutorial [3] says you need the Postfix email server, although you don't, but you do need Redis and the OpenSSH server:
# apt-get install redis-server openssh-server
So that everything works smoothly, you'll need some extra system packages, some of which you might already have installed on your system. However, just in case, use the complete install
command in Listing 1, then download Discourse from the GitHub repository.
Listing 1
Getting Discourse
Setting Up Ruby
Discourse is written in Ruby on Rails and is best run on a Ruby virtual machine (RVM). In the tutorial, the developers recommend creating a discourse user and sandboxing the RVM within it. They also recommend associating the user with a PostgreSQL account, so you should do that, too.
First, create a new user called discourse and set your password; then, create a new PostgreSQL user account, also called discourse, and set its password:
# adduser --shell /bin/bash --gecos 'Discourse application' discourse # su postgres $ createuser -s discourse $ psql -c "alter user discourse password '<yourpassword>';"
Assuming you are in the directory into which you downloaded Discourse from GitHub, you can now move the discourse
directory into the web server's root directory, pass ownership over to the discourse user, then change to the discourse user:
# mv discourse /var/www/ # chown -R discourse:discourse /var/www/discourse/ # su discourse
Note that all actions now must be performed using this user unless specified otherwise. As usual, the #
prompt indicates that you have to enter commands as root.
Now you can install the Ruby virtual machine into the discourse user and refresh your profile – remember to do this as the discourse user:
$ \curl -s -S -L https://get.rvm.io | bash -s stable $ . ~/.rvm/scripts/rvm
To build Ruby, you need to discover all the requirements, so run:
$ rvm --autolibs=read-fail requirements
On my system, this gave the list shown in Table 1. The next step is to install the missing dependencies with apt-get
, which in my case required the following command line:
Table 1
My Ruby Dependencies
libreadline6-dev |
libsqlite3-dev |
sqlite3 |
autoconf |
libgdbm-dev |
libncurses5-dev |
automake |
bison |
pkg-config |
libffi-dev |
# apt-get install libreadline6-dev \ libsqlite3-dev sqlite3 autoconf \ libgdbm-dev libncurses5-dev automake \ bison pkg-config libffi-dev
If you repeat the rvm --autolibs
… command again, you can make sure you caught all the dependencies. Now you can install Ruby, set it as the default, and install the Ruby bundler gem:
$ rvm install 2.0.0 $ rvm use 2.0.0 --default $ gem install bundler
This gem simplifies installing other gems by resolving dependencies automatically.
To get the Discourse-specific gems, move into the /var/www/discourse
directory and install:
$ cd /var/www/discourse $ bundle install --deployment --without test
At this point, you can sit back and relax, because you have a lot of downloading and installing to get through.
Configuring Discourse
Once everything has installed, change into the /var/www/discourse/config
directory and copy the discourse_quickstart.conf
file to discourse.conf
and the discourse.pill.sample
file to discourse.pill
.
You probably won't have to edit discourse.pill
, but open discourse.conf
in your favorite text editor and add or edit the values on the left of the =
signs. You can see an example (sans comments and faff) in Listing 2 (see also the "Language Support" box).
Language Support
You might want your forums in a language that is not English. Discourse supports that, too. You can see all the supported languages by running the Discourse rails console within the /var/www/discourse
directory,
$ RAILS_ENV=production bundle exec rails c
and then typing
> LocaleSiteSetting.values
from within the console. (The >
symbol is the Rails prompt, by the way.) The instruction above will dump the values contained in LocaleSiteSettings
to the Rails console output, and you will be able to see what values are available.
To change to a language different from English, say Spanish, you can enter:
> SiteSetting.default_locale = 'es'
that is, once you have checked that es is one of the values contained within LocaleSettings
.
Listing 2
Sample discourse.conf File
Remember the developers_emails
field – where you can enter a comma-separated list of email addresses for the people who will be site admins – because it can be useful when you get your site online. I will talk more about it in the "Up and Running" section, but for now, move back to the /var/www/discourse
directory and set up the database (see Listing 3).
Listing 3
Setting Up the Database
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
Endless OS 6 has Arrived
After more than a year since the last update, the latest release of Endless OS is now available for general usage.
-
Fedora Asahi 40 Remix Available for Macs with Apple Silicon
If you've been anticipating KDE's Plasma 6 for your Apple Silicon-powered Mac, then you're in luck.
-
Red Hat Adds New Deployment Option for Enterprise Linux Platforms
Red Hat has re-imagined enterprise Linux for an AI future with Image Mode.
-
OSJH and LPI Release 2024 Open Source Pros Job Survey Results
See what open source professionals look for in a new role.
-
Proton 9.0-1 Released to Improve Gaming with Steam
The latest release of Proton 9 adds several improvements and fixes an issue that has been problematic for Linux users.
-
So Long Neofetch and Thanks for the Info
Today is a day that every Linux user who enjoys bragging about their system(s) will mourn, as Neofetch has come to an end.
-
Ubuntu 24.04 Comes with a “Flaw"
If you're thinking you might want to upgrade from your current Ubuntu release to the latest, there's something you might want to consider before doing so.
-
Canonical Releases Ubuntu 24.04
After a brief pause because of the XZ vulnerability, Ubuntu 24.04 is now available for install.
-
Linux Servers Targeted by Akira Ransomware
A group of bad actors who have already extorted $42 million have their sights set on the Linux platform.
-
TUXEDO Computers Unveils Linux Laptop Featuring AMD Ryzen CPU
This latest release is the first laptop to include the new CPU from Ryzen and Linux preinstalled.