Beginners Guide to Install Discourse on Ubuntu for Development

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)

Install Discourse Dependencies

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 Discourse

Clone the Discourse repository (or your fork) in ~/discourse folder:

git clone https://github.com/discourse/discourse.git ~/discourse

Setup Database

Create role with the same name as your ubuntu system username:

sudo -u postgres createuser -s "$USER"

Bootstrap Discourse

Switch to your Discourse folder:

cd ~/discourse

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!

Create New Admin

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.

Configure Mail

Run MailCatcher:

mailcatcher --http-ip 0.0.0.0

Screen file

If you want to use GNU screen to start up rails and mailcatcher you can follow the steps in this guide.


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.

30 Likes
Beginners Guide to Install Discourse on Windows 10 for Development
HOWTO Set up a development environment using vagrant (Ubuntu guide)
Share your Discourse dev setup
Discourse Development Contribution Guidelines
Importing from vBulletin 4
Why is my dev server not showing me uploaded images in Topics?
Discourse as Your First Rails App
Rspec failing to load when using the official beginners guide
Moderation Tools
Jhead and svgo errors while running specs
Not receiving Activation Email
Docker setup for development
Importing NodeBB (MongoDB) to Discourse
Migrating from bbPress WordPress plugin to Discourse
Beginners Guide to Install Discourse on Windows 10 for Development
Install and import Mysql on the development environment
Can't uninstall on Ubuntu 18.04
Migrating to Discourse from another Forum software
How to install Discourse on windows
Share your Discourse dev setup
Discourse running very slow on local machine
Override profile background via SSO
Can't find the Discourse folder inside virtual box via ssh
Importing MyBB database to Discourse
How to install Discourse on windows
Install Discourse on Ubuntu for Development
How to create new user with verified email in development mode?
Issue in setup discourse on ubuntu server
Can't set up dev environment due to cppjieba_rb failing to install
Unable to create Vagrant local installation
Installing problem - bundle install
How to get a docker image of discourse using bash on windows 10?
Attachment filename not set on download
Importing from FluxBB
[PAID] Import from Legacy Postgres DB
Dev Category sidebar
How to add a new language
Beginner's Guide to Creating Discourse Plugins Part 1: Creating a basic plugin
Discourse Server logs show DB queries when I run the server
Using the Discourse API Ruby Gem
Does Gemfile need to include svg?
Does Gemfile need to include svg?
Find app.yml on unsupported-install
Database wont migrate Discourse
I want to build a debug version of discourse
How To Use Screen To Bootstrap A Development Install (Ubuntu)
Can I install discourse on my local machine
How Sam's Windows development environment is configured
How to reset discourse on dev mode? (w/o docker)
Migrating from Ning to Discourse
Beginners Guide to Install Discourse on Windows 10 for Development
Nodebb to Discourse
Beginners Guide to Install Discourse on Windows 10 for Development
Beginners Guide to Install Discourse on Windows 10 for Development
Importing from Kunena 3
RSpec search_spec.rb RateLimiter LimitExceeded problems
Discourse as Your First Rails App
Issue with vagrant version following the dev guide
NULL first_visited_at dates in the topic_users table
Multiple instances. Visiting the second instance signs out the logged in account on the running instance
Can't run my Discourse locally
Importing from phpBB3
I want to install a plugin for development, what should I do?
Mini_racer installation issues on ubuntu vagrant (OSX)
Bundle exec rake fails
Vbulletin 4 import -
Hello from Gitpod! (installing on google cloud + automated dev setup)
How to Install Discourse on LocalHost in Windows?
Importing Phorum to Discourse
Importing PunBB to Discourse
Migration from Yahoo! Groups
Does the forum for development start up 24 hours*?
Two issues: Are they related to sidekiq? uninitialized constant Jobs::Jobs ::Scheduled (Discourse Newbie)
How to allow customs hosts in development mode
Importing MyBB to Discourse
Any interest in Podman?
Beginners Guide to Install Discourse for Development using Docker
How might we better structure #howto?
Please help, how do I install Discourse on macOS?
How might we better structure #howto?
Installing Plugins in Discourse Development Install
Site setting is different Every time on Ubuntu development installation
Importing MyBB to Discourse
Export only database data Postgres (for users, posts and topics)
Setting up Discourse for development on Fedora
How to open via internal IP?
Discourse Local setup
Is this correct? How long to install dev Version?
Overriding user_guardian.rb in a plugin (no fork necessary!)
Overriding user_guardian.rb in a plugin (no fork necessary!)
Can't reach Discourse server in VM from Host
Importing MyBB to Discourse
Rails Console Error: FATAL: Peer authentication failed for user "discourse"
Rails Console Error: FATAL: Peer authentication failed for user "discourse"
Unable to Install Discourse for development
Docker in VMWare - How to access to Discourse
How can I make my own Discourse plugins?
Beginners Guide to Install Discourse on Windows 10 for Development
What is the latest recommended workflow for local development? (Ubuntu 16.04)
What is the latest recommended workflow for local development? (Ubuntu 16.04)
How to customize the Discourse app using docker container?
Update PhantomJS to latest for Ubuntu dev guide?
A check for updates has not been performed lately. Ensure sidekiq is running
How to fix bundler executable conflicts in the `techAPJ/install-rails` script?
Ubuntu development install: Permission denied @ apply2files
Install discourse on localhost
Trouble getting a top level page to Ember
Formal german available?
Any interest in Podman?
Importing NodeBB (Redis) to Discourse
Rake aborted message is showing when installing vagrant development
Where is the db connection information discourse?
How to install the bootsnap gem?
Google Groups Import Script Fails (Due to Invalid Browser)
MailCatcher not catching email
Migrating from GetSatisfaction to Discourse
State of disqus to discourse importer
Connecting to Droplet
Connecting to Droplet
Best way to install Discourse on my Linux Mint Desktop?

I ran into the same problem today when following Beginners Guide to Install Discourse for Development using Docker .

I just added require 'fileutils' at the beginning of bin/unicorn. This solved the issue and the local dev instance spun up as desired.

However, it seems strange that this problem apparently does not exist for production instances or for other developers. I did not take a deeper look, why it might work for others without the explicit import.

6 Likes
dle exec rails server --binding=0.0.0.0
/usr/bin/ruby2.7: warning: shebang line ending with \r may cause problems
/usr/bin/env: ‘ruby\r’: No such file or directory