How do I install Discourse on Ubuntu?

The instructions assume you need vagrant to install Ubuntu, and are apparently geared towards people mainly using Windows or Mac and who would benefit from a separate VM to install and play with discourse. If Seth has an "Ubuntu machine lying around" with 13.04 already installed, he can just clone the git repo and set it up locally.

Setting things up locally and manually is documented here on GitHub. However it does seem a bit complex, the vagrant VM has all the needed services (pgsql, redis) already preconfigured so may be easier to get started with.

That said, if you're feeling brave, you can follow these steps to install and configure things on your local Ubuntu machine.

Disclaimer, it is a complex procedure that involves many moving parts, I tested this procedure on a freshly installed 13.04 system but if things go wrong, you should be prepared to decypher error messages and fix things. You should be comfortable with:

  • Ubuntu package installation.
  • Text file editing.
  • Having some knowledge of Postgres commandline usage.
  • Being minimally familiar with Ruby, Rails and rubygems.
  • Some git doesn't hurt, but it's only used for the initial cloning phase

OK, here goes

Install needed packages:

sudo apt-get install git ruby ruby-bundler build-essential libxml2-dev libxslt1-dev redis-server postgresql libpq-dev postgresql-contrib-9.1

Create a postgresql database and grant permissions to the user who is going to run discourse (I'll assume it's named "john", it could/should be your username):

sudo -u postgres createdb discourse_development
sudo -u postgres psql -c "create user john with password 'whatever' "
sudo -u postgres psql -c "grant all privileges on database discourse_development to john"
#This is a bit of postgresql magic to add the required hstore and pg_trgm extensions
sudo -u postgres psql discourse_development -c "create extension hstore; create extension pg_trgm"

Clone the repository:

git clone https://github.com/discourse/discourse
cd discourse

Use Bundler to install ruby gems and dependencies including rails:

bundle install

You may run into dependency problems here, as other packages may be needed to build native extensions. If you get yellow text with errors in this step, look at the error messages to figure out which packages to install (with apt-get).

Configure the database data (postgres and redis):

cp config/redis.yml.sample config/redis.yml
cp config/database.yml.sample config/database.yml
# Now edit config/database.yml and in the discourse_development section add
# username: john
# password: whatever
# Follow the format for the other entries (adapter:, database:)

Run the migrations to initialize the database, then seed it:

bundle exec rake db:migrate
bundle exec rake db:seed_fu
sudo -u postgres psql discourse_development < pg_dumps/production-image.sql

then launch the development web server:

bundle exec rails s

Finally, open your browser and connect to the local dev server at

http://localhost:3000

Cloud deployment (with Juju)

If you have a cloud provider and want to skip a lot of manual jumping around, you can use the Juju charm!

After you've successfully bootstrapped an environment, run the following:

juju deploy cs:~marcoceppi/discourse
juju deploy postgresql

Then create relations

juju add-relation discourse postgresql:db-admin

Discourse requires db-admin level access in order to enable the hstore plugin. Finally, expose discourse:

juju expose discourse

Configuration and other caveats can be found in the Charm's README. These options include configuring admins, where to fetch the Discourse source, version pinning, and other tuning options.

Disclaimer, I am the author of this charm.


Bare Metal

I've just completed an article describing this exact process

In summary, you need to:

  • Install and configure PostgreSQL
  • Install Redis and Ruby 1.9.3+
  • Clone the Discourse Git repository
  • Make the appropriate config. changes
  • Run bundle exec rails server

The project itself also has documentation on how to install on Ubuntu using Docker (which is the only officially supported way):

For development you can use this program which is a simple single command after you install Docker.