This guide is aimed at advanced Rails developers who have installed their own Rails apps before. If you are new to Rails, you are likely much better off with our Discourse Vagrant Developer Guide.

Note: If you are developing on a Mac, you will probably want to look at these instructions as well.

First Steps

  1. Install and configure PostgreSQL 9.3+.
  2. Run postgres -V to see if you already have it.
  3. Make sure that the server’s messages language is English; this is required by the ActiveRecord Postgres adapter.
  4. Install and configure Redis 2+.
  5. Run redis-server -v to see if you already have it.
  6. Install ImageMagick
  7. Install libxml2, libpq-dev, g++, gifsicle, libjpeg-progs and make.
  8. Install Ruby 2.1.3 and Bundler.
  9. Clone the project and bundle.

Before you start Rails

  1. bundle install
  2. Start up Redis by running redis-server
  3. bundle exec rake db:create db:migrate db:test:prepare
  4. Try running the specs: bundle exec rake autospec
  5. bundle exec rails server

You should now be able to connect to rails on http://localhost:3000 - try it out! The seed data includes a pinned topic that explains how to get an admin account, so start there! Happy hacking!

Building your own Vagrant VM

Here are the steps we used to create the Vagrant Virtual Machine. They might be useful if you plan on setting up an environment from scratch on Linux:

Base box

Vagrant version 1.1.2. With this Vagrantfile: do |config|     = 'precise32'
  config.vm.box_url = '' :hostonly, ''

  if RUBY_PLATFORM =~ /darwin/
    config.vm.share_folder("v-root", "/vagrant", ".", :nfs => true)

vagrant up
vagrant ssh

Some basic setup:

sudo su -
ln -sf /usr/share/zoneinfo/Canada/Eastern /etc/localtime
apt-get -yqq update
apt-get -yqq install python-software-properties
apt-get -yqq install vim curl expect debconf-utils git-core build-essential zlib1g-dev libssl-dev openssl libcurl4-openssl-dev libreadline6-dev libpcre3 libpcre3-dev imagemagick


echo "export LANGUAGE=en_US.UTF-8" >> /etc/bash.bashrc
echo "export LANG=en_US.UTF-8" >> /etc/bash.bashrc
echo "export LC_ALL=en_US.UTF-8" >> /etc/bash.bashrc
export LANGUAGE=en_US.UTF-8
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8

locale-gen en_US.UTF-8
dpkg-reconfigure locales

RVM and Ruby

apt-get -yqq install libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion pkg-config curl build-essential git

su - vagrant -c "sudo bash -s stable > /etc/gemrc
su - vagrant -c "echo 'gem: --no-document' >> ~/.gemrc"


Configure so that the vagrant user doesn’t need to provide username and password.

apt-get -yqq install postgresql postgresql-contrib-9.3 libpq-dev postgresql-server-dev-9.3
su - postgres
createuser --createdb --superuser -Upostgres vagrant
psql -c "ALTER USER vagrant WITH PASSWORD 'password';"
psql -c "create database discourse_development owner vagrant encoding 'UTF8' TEMPLATE template0;"
psql -c "create database discourse_test        owner vagrant encoding 'UTF8' TEMPLATE template0;"
psql -d discourse_development -c "CREATE EXTENSION hstore;"
psql -d discourse_development -c "CREATE EXTENSION pg_trgm;"

Edit /etc/postgresql/9.3/main/pg_hba.conf to have this:

local all all trust
host all all trust
host all all ::1/128 trust
host all all trust # wide-open


sudo su -
mkdir /tmp/redis_install
cd /tmp/redis_install
tar xvf redis-2.6.7.tar.gz
cd redis-2.6.7
make install
cd utils
# Press enter to accept all the defaults
/etc/init.d/redis_6379 start

Sending email (SMTP)

By default, development.rb will attempt to connect locally to send email.

config.action_mailer.smtp_settings = { address: "localhost", port: 1025 }

Set up MailCatcher so the app can intercept
outbound email and you can verify what is being sent.

Note also that mail is sent asynchronously by Sidekiq, so you’ll need to have it running to process jobs. Run it with this command:

bundle exec sidekiq


Needed to run javascript tests.

cd /usr/local/share
tar xvf phantomjs-1.8.2-linux-i686.tar.bz2
rm phantomjs-1.8.2-linux-i686.tar.bz2
ln -s /usr/local/share/phantomjs-1.8.2-linux-i686/bin/phantomjs /usr/local/bin/phantomjs