Local multisite development setup

It’s possible to run discourse in multisite mode in development. A multisite server uses a different DB and hostname for each site that it serves. This is useful if you are developing a feature or a plugin that should be multisite compatible.

All you need to do is add an appropriate config/multisite.yml file. i.e:

---
alternate:
  adapter: postgresql
  database: alternate
  host_names:
  - alternate.localhost

To run rake tasks against these extra sites, simply add the RAILS_DB environment variable with the name of the site that you are targeting. To create and migrate your new site’s db:

RAILS_DB=alternate rake db:create
RAILS_DB=alternate rake db:migrate

Running rake tasks without RAILS_DB set will target the default site.

You’ll need to run allow ember cli bypassing (since ember-cli doesn’t forward the host):

ALLOW_EMBER_CLI_PROXY_BYPASS=1 rails server

However, you’ll also need to run ember-cli, since it is used to generate assets.

You may now be able to view the your new site at http://alternate.localhost:3000, but if your cannot, you may need to add alternate.localhost to your /etc/hosts file or equivalent.

7 Likes