Discourse – Bringing civilized discussion to the Internet

Being Civil

© Lead Image © Svitlana Martynova, 123RF.com

© Lead Image © Svitlana Martynova, 123RF.com

Article from Issue 169/2014
Author(s):

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.

Figure 1: Discourse meta [2] is the Discourse Internet forum that discusses matters concerning Discourse itself.

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

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • Welcome

    The sorry state of discourse on the Internet has many causes, and the experts have offered many solutions for the mess. One of the biggest problems is the way that social media platforms reward engagement.

  • diaspora*

    You don't need Facebook to keep up with your friends online. With diaspora*, you get a similar experience without the spying.

  • A New Chrome OS-Like Ubuntu Remix is Now Available

    Ubuntu Web looks to be your Chrome OS alternative.

  • News

    In the news: Gnome 44 Release Candidate; Flathub Vying to Become the Standard Linux App Store; Debian 12 to Ship with KDE Plasma 5.27; Planet Computers Launches ARM-Based Linux Desktop PCs; Ubuntu No Longer Shipping with Flatpak; openSUSE Leap 15.5 Beta; Linux Kernel 6.2 Released with NewHardware Support; Kubuntu Focus Team Releases NewMini Desktop; and US National Cybersecurity Strategy Released.

  • Distro Walk – blendOS

    blendOS uses container technology to allow different distributions to coexist on a single desktop environment. Bruce talks to Rudra Saraswat, blendOS's 13-year-old developer.

comments powered by Disqus
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.

Learn More

News