Sites
Sites Directory
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
apps.txt
contain a list of Python packages to treat as Frappe apps. Every
frappe app that you intend to use in your site should have an entry in this file.
Also, they should be in the PYTHONPATH
. For more information, refer
Frappe Apps.
common\site\config.json
common_site_config.json
is an optional file. Configuration common to all sites
can be put in this file.
assets
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
languages.txt
is an autogenerated file which maps every language to it's code.
Site
A site is a directory in sites_dir
which represents a tenant in Frappe Platform.
Directory Structure
site ├── locks ├── private │ └── backups ├── public │ └── files │ └── testfile.txt └── site_config.json
locks
directory is used by the scheduler to synchronize various jobs using the file locking concept.private
directory contains files that require authentication to access. Presently, it is limited only to backups.public
directory contains files that can directly served. In the above example,testfile.txt
can be accessed by the URL, http://site/files/testfile.txtsite_config.json
contains site specific configuration
Site Config
See configuration options for site_config.json
Site Resolution
While responding to an HTTP request, a site is automatically selected based on,
Host
header in the HTTP request matches a siteX-Frappe-Site-Name
header 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.