title | short_title | id |
---|---|---|
Install Discourse on macOS for development |
macOS setup |
macos-setup |
⚠️ This guide covers installation instructions for a macOS development environment, for production guides see: https://meta.discourse.org/t/how-to-install-discourse-in-production/142537
So you want to set up Discourse on macOS to hack on and develop with?
We'll assume that you don't have Ruby/Rails/Postgres/Redis installed on your Mac. Let's begin 🚀 !
You will need the following new packages on your system:
- Git
- rbenv or asdf
- ruby-build
- Ruby (latest stable)
- Rails
- PostgreSQL
- SQLite
- Redis
- Node.js
- pnpm
- MailHog
- ImageMagick
restart your terminal
Now that we have installed Discourse dependencies, let's move on to install Discourse itself.
Exit your shell and restarting it ensures that the paths to the installed packages are correctly picked up by the Terminal.
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.
Switch to your Discourse folder:
cd ~/discourse
Install the needed gems
bundle install
Install the JS dependencies
pnpm install
Next, run these commands to set up your local Discourse instance:
bundle exec rake db:create
bundle exec rake db:migrate
RAILS_ENV=test bundle exec rake db:create db:migrate
Start rails + Ember servers, you have two options here.
Option 1: using two separate Terminal tabs/windows, run Rails and Ember CLI separately via
bundle exec rails server
and
bin/ember-cli
Option 2: using only one Terminal tab/window:
bin/ember-cli -u # will run the Unicorn server in the background
🎉 You should now be able to navigate to http://localhost:4200 to see your local Discourse installation. (Note that the first load can take up to a minute as the server is warmed up.)
You can also try running the specs:
bundle exec rake autospec
All (or almost all) the tests should pass.
To create a new admin, run the following command:
RAILS_ENV=development bundle exec rake admin:create
Follow the prompts to create an admin account.
Run MailHog:
mailhog
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.