This guide is aimed at Developers who wants to set up Discourse on Ubuntu system, for hacking pleasure. In this guide we'll assume that you don't have Ruby/Rails/Postgre/Redis pre installed (set up instructions may vary, in case you have pre-installed Ruby/Rails/Postgre/Redis).
(NOTE: If you want to install Discourse for production purpose, this is the guide you are looking for: https://meta.discourse.org/t/beginners-guide-to-deploy-discourse-on-digital-ocean-using-docker/12156)
Discourse Dependencies
Run this script, to setup Rails development environment:
bash <(wget -qO- https://raw.github.com/techAPJ/install-rails/master/linux)
This will install following new packages on your system:
Install Phantomjs:
cd /usr/local/share
sudo wget https://phantomjs.googlecode.com/files/phantomjs-1.9.0-linux-i686.tar.bz2
sudo tar xvf phantomjs-1.9.0-linux-i686.tar.bz2
sudo rm phantomjs-1.9.0-linux-i686.tar.bz2
sudo ln -s /usr/local/share/phantomjs-1.9.0-linux-i686/bin/phantomjs /usr/local/bin/phantomjs
cd
Now that we have installed Discourse dependencies, let's move on to install Discourse itself.
Clone Discourse
Clone the Discourse repository in ~/discourse
folder:
git clone https://github.com/discourse/discourse.git ~/discourse
Setup Database
Open psql prompt as postgre user
sudo -u postgres psql postgres
Create discourse role with discourse as password:
CREATE ROLE discourse WITH LOGIN ENCRYPTED PASSWORD 'discourse' CREATEDB SUPERUSER;
Check that you have successfully created discourse role:
\du
Create discourse_development and discourse_test database:
CREATE DATABASE discourse_development WITH OWNER discourse ENCODING 'UTF8' TEMPLATE template0;
CREATE DATABASE discourse_test WITH OWNER discourse ENCODING 'UTF8' TEMPLATE template0;
Exit psql prompt by pressing ctrld
Now access psql prompt in discourse_development database as discourse user:
psql -d discourse_development -U discourse -h localhost
When prompted for password, provide the password which you set at the time of creating role, if you followed the guide as is, the password is discourse
Run following commands, separately:
CREATE EXTENSION pg_trgm;
CREATE EXTENSION hstore;
Exit psql prompt by pressing ctrld
Now access psql prompt in discourse_test database as discourse user:
psql -d discourse_test -U discourse -h localhost
When prompted for password, provide the password which you set at the time of creating role, if you followed the guide as is, the password is discourse
Run following commands, separately:
CREATE EXTENSION pg_trgm;
CREATE EXTENSION hstore;
Exit psql prompt by pressing ctrld
You have set the database setings successfully!
Bootstrap Discourse
Switch to your Discourse folder:
cd ~/discourse
Install the needed gems
bundle install
Before seeding database you will need to modify discourse/config/database.yml
file:
Add these lines to development and test database settings:
username: discourse
password: discourse
host: localhost
(In case you provided password other than discourse while creating role discourse, be sure to modify the file accordingly.)
Now that you have successfully configured database connection, run this command:
bundle exec rake db:migrate db:test:prepare db:seed_fu
Now, try running the specs:
bundle exec rake autospec
Start rails server:
bundle exec rails server
You should now be able to connect to discourse app on http://localhost:3000 - try it out!
Access Admin
Since we do not have mail configured yet, the best way to get a working account is to sign up through Google Account:
Once you will successfully verify your Google credentials, you will have a working Discourse account.
Now, to make your account as admin, enter the following commands in rails console:
RAILS_ENV=development bundle exec rails c
u = User.last
u.admin = true
u.save
Once you execute the above commands successfully, check out your Discourse account again:
Congratulations! You are now the admin of your own Discourse installation!
Happy hacking!
If anything needs to be improved in this guide, feel free to ask on meta.discourse.org, or even better, submit a pull request.