Frappe is a multitenant platform and each tenant is called a site. Sites exist
in a directory called
sites, assumed as the current working directory when
running a frappe command or other services like Celery worker or a WSGI server.
You can set
sites_dir with an environment variable
SITES_DIR or pass
--sites_dir option to the frappe command.
Apart from the sites, the
sites_dir should contain the following.
apps.txt contain a list of Python packages to treat as Frappe apps. Every
frappe app that you intend to use in you site should have an entry in this file.
Also, they should be in the
PYTHONPATH. For more information, refer
common_site_config.json is an optional file. Configuration common to all sites
can be put in this file.
Assets contain files that are required to be served for the browser client.
These generally include *.js, *.css, *.png files. This directory is auto
generated using the
bench build command.
languages.txt is an autogenerated file which maps every language to it's code.
A site is a directory in
sites_dir which represents a tenant in Frappe Platform.
site ├── locks ├── private │ └── backups ├── public │ └── files │ └── testfile.txt └── site_config.json
locksdirectory is used by the scheduler to synchronize various jobs using the file locking concept.
privatedirectory contains files that require authentication to access. Presently, it is limited only to backups.
publicdirectory contains files that can directly served. In the above example,
testfile.txtcan be accessed by the URL, http://site/files/testfile.txt
site_config.jsoncontains site specific configuration
While responding to an HTTP request, a site is automatically selected based on,
Hostheader in the HTTP request matches a site
X-Frappe-Site-Nameheader in the HTTP request matches a site
It is also possible to force the development server to serve a specific site by
starting it with the following command.
bench --site SITENAME serve
Adding a new site
To add a new site, execute the following command in your bench instance:
bench new-site SITENAME
Set a site as the current site
To force a site to be used as the default site, execute the following:
bench use SITENAME
To make sure, check the contents of
currentsite.txt (found in the
sites folder of your bench instance) and it should have SITENAME.