2013-02-12 11:18:59 -05:00
# Discourse Advanced Developer Install Guide
This guide is aimed at advanced Rails developers who have installed their own Rails apps before. If you are new
2013-02-13 07:20:57 -05:00
to rails, you are likely much better off with our ** [Discourse Vagrant Developer Guide ](https://github.com/discourse/discourse/blob/master/docs/VAGRANT.md )**.
2013-02-12 11:18:59 -05:00
## First Steps
2013-02-24 08:42:37 -05:00
1. Install and configure PostgreSQL 9.1+. Make sure that the server's messages language is English; this is [required ](https://github.com/rails/rails/blob/3006c59bc7a50c925f6b744447f1d94533a64241/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb#L1140 ) by the ActiveRecord Postgres adapter.
2013-02-12 11:18:59 -05:00
2. Install and configure Redis 2+
2013-02-14 16:11:54 -05:00
3. Install Ruby 1.9.3 and Bundler.
2013-02-12 11:18:59 -05:00
3. Clone the project.
4. Create development and test databases in postgres.
2013-02-14 10:33:22 -05:00
5. Copy `config/database.yml.sample` and `config/redis.yml.sample` to `config/database.yml` and `config/redis.yml` and input the correct values to point to your postgres and redis instances.
2013-03-19 13:39:16 -04:00
6. Install the seed data to set up an admin account and meta topic: `psql DATABASE_NAME < pg_dumps/production-image.sql`
2013-02-12 11:18:59 -05:00
## Before you start Rails
1. `bundle install`
2013-03-19 13:39:16 -04:00
2. `rake db:migrate`
3. `rake db:test:prepare`
4. `rake db:seed_fu`
5. Try running the specs: `bundle exec rspec`
6. `bundle exec rails server`
2013-02-12 11:18:59 -05:00
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!
2013-02-12 11:39:32 -05:00
# Building your own Vagrant VM
2013-02-12 11:18:59 -05:00
2013-02-13 07:20:57 -05:00
Here are the steps we used to create the ** [Vagrant Virtual Machine ](https://github.com/discourse/discourse/blob/master/docs/VAGRANT.md )**. They might be useful if you plan on setting up an environment from scratch on Linux:
2013-02-12 11:18:59 -05:00
## Base box
2013-03-19 13:39:16 -04:00
Vagrant version 1.1.2. With this Vagrantfile:
2013-02-12 11:18:59 -05:00
Vagrant::Config.run do |config|
config.vm.box = 'precise32'
config.vm.box_url = 'http://files.vagrantup.com/precise32.box'
config.vm.network :hostonly, '192.168.10.200'
2013-02-26 12:45:56 -05:00
2013-02-12 11:18:59 -05:00
if RUBY_PLATFORM =~ /darwin/
config.vm.share_folder("v-root", "/vagrant", ".", :nfs => true)
end
end
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
## Unicode
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
2013-02-26 12:45:56 -05:00
2013-02-12 11:18:59 -05:00
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
2013-02-26 12:45:56 -05:00
2013-02-12 11:18:59 -05:00
su - vagrant -c "sudo bash -s stable < < (curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)"
adduser vagrant rvm
source /etc/profile.d/rvm.sh
su - vagrant -c "rvm pkg install libyaml"
2013-03-19 13:39:16 -04:00
su - vagrant -c "rvm install 2.0.0-turbo"
su - vagrant -c "rvm use 2.0.0-turbo --default"
2013-02-26 12:45:56 -05:00
2013-02-12 11:18:59 -05:00
echo "gem: --no-rdoc --no-ri" >> /etc/gemrc
su - vagrant -c "echo 'gem: --no-rdoc --no-ri' >> ~/.gemrc"
## Postgres 9.1
Configure so that the vagrant user doesn't need to provide username and password.
apt-get -yqq install postgresql postgresql-contrib-9.1 libpq-dev postgresql-server-dev-9.1
su - postgres
psql -c "CREATE USER vagrant WITH PASSWORD 'password';"
psql -c "ALTER USER vagrant WITH PASSWORD 'password';"
createdb vagrant
psql -c "CREATE EXTENSION hstore;"
2013-03-19 13:39:16 -04:00
psql -c "CREATE EXTENSION pg_trgm;"
2013-02-12 11:18:59 -05:00
psql -c "ALTER USER vagrant CREATEDB"
psql -c "create database discourse_development owner vagrant encoding 'UTF8' TEMPLATE template0;"
psql -c "create database discourse_test owner vagrant encoding 'UTF8' TEMPLATE template0;"
Also, a user "discourse" is needed when importing a database image.
createuser --createdb --superuser discourse
psql -c "ALTER USER discourse WITH PASSWORD 'password';"
Edit /etc/postgresql/9.1/main/pg_hba.conf to have this:
2013-02-26 12:45:56 -05:00
local all all trust
2013-02-12 11:18:59 -05:00
host all all 127.0.0.1/32 trust
host all all ::1/128 trust
host all all 0.0.0.0/0 trust # wide-open
2013-03-19 13:39:16 -04:00
Load the seed data (as vagrant user):
2013-02-12 11:18:59 -05:00
2013-03-19 13:39:16 -04:00
psql -d discourse_development < pg_dump / development-image . sql
2013-02-12 11:18:59 -05:00
2013-03-19 13:39:16 -04:00
(You may wish to try the `production-image.sql` file for a good seed for a production database.)
2013-02-12 11:18:59 -05:00
## Redis
mkdir /tmp/redis_install
cd /tmp/redis_install
wget http://redis.googlecode.com/files/redis-2.6.7.tar.gz
tar xvf redis-2.6.7.tar.gz
cd redis-2.6.7
make
make install
cd utils
./install_server.sh
# Press enter to accept all the defaults
2013-02-13 07:20:57 -05:00
/etc/init.d/redis_6379 start
2013-02-16 23:55:43 -05:00