Now, that we have created our first site, we can access it on http://localhost:8000 in our browser.
However, bench
allows you to create multiple sites and access them separately in
the browser on the same port. This is what we call multi-tenancy support in
bench.
To achieve that, we must disable the serving of the default site. Go back to
your terminal and delete the file sites/currentsite.txt
from the
frappe-bench
directory.
$ rm sites/currentsite.txt
Now, you won't be able to access your site on http://localhost:8000.
Frappe will identify which site to serve by matching the hostname of the request
with the site name, so you should be able to access your site on
http://library.test:8000 but this won't work because
we have to tell our operating system that library.test should point to
localhost. To do that, you can add the following entry to your /etc/hosts
file.
127.0.0.1 library.test
This will map library.test
to localhost
. Bench has a convenient command to do
just that.
$ bench --site library.test add-to-hosts
This will ask for your root password and will add an entry to your /etc/hosts
file.
Great, now you can access your site at http://library.test:8000. Congratulations for making it this far.