Installing Discourse on Ubuntu

Nathan Osman's Gravatar

Nathan Osman
published June 1, 2013, 8:32 p.m.

Note: these instructions are written specifically for Raring Ringtail (Ubuntu 13.04) and are not guaranteed to work on other releases. Please leave a comment below if you are using a newer release and having difficulty with the instructions.

Discourse is a modern Q&A platform brought to you by the same people that wrote Stack Overflow (or some of them anyway). Being the curious type, I decided to install all of the prerequisites and document the installation process below.

This process is quite involved but should work if you carefully follow the instructions. These instructions are a blend of what you find here, what you find here, and some of my own wisdom.

Setting Up PostgreSQL

PostgreSQL is an integral part of Discourse, so naturally it is important that we set up the PostgreSQL server properly.

  1. Install the server:

    sudo apt-get install postgresql postgresql-contrib postgresql-server-dev-9.1
  2. Open a terminal and run the following command:

    sudo -u postgres psql postgres

    We now have a PostgreSQL interactive prompt, which we can use to create the user and database we will need later.

  3. Enter the following command at the prompt:


    Replace xxx with your username. If you're not sure what your username is, run the appropriately named whoami command. The password is not important and can be set to any value.

  4. Now create the database that Discourse will later use with the following command:


    Replace xxx with your username. This creates the database and assigns the discourse user we previously created as the owner.

Setting Up Redis

Redis acts as a key/value store, providing a simple but extremely efficient means of caching data.

  1. Install Redis:

    sudo apt-get install redis-server
  2. That's it. (Easy, huh?)

Setting Up Ruby

Discourse is written in Ruby, so it only follows that we need the interpreter to run the application.

  1. In addition to the ruby package, we also need bundler. Note that we use a specific version of Ruby:

    sudo apt-get install ruby1.9.3 bundler
  2. That's it. (This is almost fun, eh?)

Setting Up Discourse

Now for the fun part.

  1. Navigate to a directory of your choice where the Discourse source code will be installed. For the sake of this example, we will use ~/discourse.

  2. Clone the Discourse Git repository:

    sudo apt-get install git
    git clone git://
  3. Copy the configuration templates to their appropriate locations:

    cp config/database.yml.development-sample config/database.yml
    cp config/redis.yml.sample config/redis.yml
  4. Open the config/database.yml file in a text editor of your choice. Edit the contents to match what you see below:

      adapter: postgresql
      database: xxx
      pool: 5
      timeout: 5000
        - localhost

    Again, replace xxx with your username.

  5. Open the config/redis.yml file and edit the contents to match what you see below:

      uri: redis://localhost:6379
      host: localhost
      port: 6379
      db: 0
      cache_db: 2
  6. Next run the following command to install all required gems:

    bundle install
    rake db:migrate

    Note that these commands may take some time to complete.

  7. Launch the server with the following command:

    bundle exec rails server
  8. If everything installed without error, then you should be able to open the following link in your browser to view your new installation: