So you want to set up Discourse on Mac OS X to hack on and develop with?
We’ll assume that you don’t have Ruby/Rails/Postgre/Redis installed on your Mac. Let’s begin!
(If you want to install Discourse for production use, see our install guide)
Install Discourse Dependencies
Run this script in terminal, to setup Rails development environment:
bash
This script will install following new packages on your system:
- Git
- rbenv
- ruby-build
- Ruby (latest stable)
- Rails
- PostgreSQL
- Redis
- Bundler
- ImageMagick
- PhantomJS
In case you have any of this package pre-installed and don’t want to run entire script, see the script and pick the packages you don’t have currently installed. The script is fine-tuned for Discourse, and includes all the packages required for Discourse installation.
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
~
indicates home folder, so Discourse source code will be available in your home folder.
Setup Database
Open psql prompt:
psql postgres
Create discourse_development and discourse_test database with your account short name specified as role:
CREATE DATABASE discourse_development WITH OWNER techapj ENCODING 'UTF8' TEMPLATE template0;
CREATE DATABASE discourse_test WITH OWNER techapj ENCODING 'UTF8' TEMPLATE template0;
Note that in above commands I specified the role as techapj, this means that my short name is techapj, replace this with your own short name.
Exit psql prompt by pressing controld
Now access psql prompt in discourse_development database as your short name user:
psql -d discourse_development -U techapj -h localhost
Run following commands, separately:
CREATE EXTENSION pg_trgm;
CREATE EXTENSION hstore;
Exit psql prompt by pressing controld
Now access psql prompt in discourse_test database as your short name user:
psql -d discourse_test -U techapj -h localhost
Run following commands, separately:
CREATE EXTENSION pg_trgm;
CREATE EXTENSION hstore;
Exit psql prompt by pressing controld
You have set-up the database successfully!
Bootstrap Discourse
Switch to your Discourse folder:
cd ~/discourse
Install the needed gems
bundle install
Now that you have successfully installed gems, run this command:
bundle exec rake db:migrate db:test:prepare db:seed_fu
Try running the specs:
bundle exec rake autospec
All the tests should pass.
Start rails server:
bundle exec rails server
You should now be able to connect with your Discourse app on http://localhost:3000 - try it out!
Create New Admin
To create a new admin, run the following commands in rails console:
RAILS_ENV=development bundle exec rake admin:create
Just enter your input as suggested, you can create an admin account.
Happy hacking! And to get started with that, see Beginner’s Guide to Creating Discourse Plugins.
Source: https://meta.discourse.org/t/beginners-guide-to-install-discourse-on-mac-os-x-for-development/15772