This guide covers installation instructions in development environment, for a production guide see: How to install Discourse in production
So you want to set up Discourse on Ubuntu to hack on and develop with?
We’ll assume that you don’t have Ruby/Rails/Postgre/Redis installed on your Ubuntu system. Let’s begin!
Although this guide assumes that you are using Ubuntu, but the set-up instructions will work fine for any Debian based distribution.
(If you want to install Discourse for production use, see our install guide)
As regular user run this script in terminal, to setup Rails development environment:
bash <(wget -qO- https://raw.githubusercontent.com/techAPJ/install-rails/master/linux)
This will install following new packages on your system:
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 the Discourse repository (or your fork) in
git clone https://github.com/discourse/discourse.git ~/discourse
Create role with the same name as your ubuntu system username:
sudo -u postgres createuser -s "$USER"
Switch to your Discourse folder:
Install the needed gems
source ~/.bashrc bundle install
Now that you have successfully configured database connection, run these commands:
bundle exec rake db:create bundle exec rake db:migrate RAILS_ENV=test bundle exec rake db:create db:migrate
Now, try running the specs:
bundle exec rake autospec
Start rails server: (to have it available only on localhost)
bundle exec rails server
or use this command to have it listening on all interfaces and available remotely
bundle exec rails server --binding=0.0.0.0
You should now be able to connect to discourse app on http://localhost:3000 - try it out!
To create a new admin, run the following command:
RAILS_ENV=development bundle exec rake admin:create
Follow the prompts, and a new admin account will be created.
Congratulations! You are now the admin of your own Discourse installation!
Happy hacking! And to get started with that, see Beginner’s Guide to Creating Discourse Plugins.