This guide covers installation instructions in development environment, for a production guide see: How to install Discourse in production (Discourse official install / standard install)
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/Postgres/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.
This guide has been confirmed to be working without the use of any additional steps on Ubuntu 18.
Depending on what version of Ubuntu/Debian you’re using to install Discourse, you may want to review the following:
Notes about Installing Discourse on Ubuntu 20.04 or later
By default, Ubuntu version 20.04 comes preinstalled with OpenSSL 3.0.2. You’ll likely want to compile an earlier version of OpenSSL from source (we recommend OpenSSL-1.1.1n). You’ll also want to check what version of Ruby you’re using with
ruby --version Discourse still uses Ruby 2, so if you’re using Ruby 3.x or later you’ll need to use an earlier version. We recommend using a version manager for Ruby here, and we’ve found that Ruby 2.7.6 is currently the best version to use with Discourse. See Notes about Installing Discourse on Ubuntu 20.04 for more details about this.
Ubuntu 22.04 Warning for Early Adopters
This section added by @pfaffman 22.05.16 and should one day be wrong and the suggestion unnecessary.
NOTE: This won’t work for Ubuntu 22.04 just yet. If you are forced to use 22.04 (I was using Pop! OS), see Failed to build ruby 2.7.5 on ubuntu 22.04 · Discussion #1940 · rbenv/ruby-build · GitHub for how to compile a compatible version of openssl.
End of @pfaffman additions.
As regular user run this script in terminal, to setup Rails development environment:-
bash <(wget -qO- https://raw.githubusercontent.com/discourse/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 in
git clone https://github.com/discourse/discourse.git ~/discourse
~ indicates home folder, so Discourse source code will be available in your home folder.
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 installed gems, run these commands:
bundle exec rake db:create bundle exec rake db:migrate RAILS_ENV=test bundle exec rake db:create db:migrate
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!
Starting with Discourse 2.5+ EmberCLI is required in development and these additional steps will be required:
In a separate terminal instance, navigate to your discourse folder (
cd ~/discourse) and run:
You should now be able to navigate to http://localhost:4200 to see your local Discourse installation.
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.
Last Reviewed by @AlexDev on 2022-05-26T19:00:00Z