Skip to main content

Frappe Sites in Frappe Framework (v15): Complete Documentation

Introduction — What Are Sites in Frappe?

A Site in the Frappe Framework is a self-contained environment that stores:

  • Its own database
  • Its own files and private files
  • Its own site configuration (site_config.json)
  • References to installed apps
  • Authentication, users, permissions
  • Cache, logs, and runtime settings

In simple terms:

  • An App contains features
  • A Site stores data and configuration

One app can be installed on multiple sites, and each site can have multiple apps installed—making Frappe a powerful multi-tenant platform.

How Sites Work in Frappe Framework v15

A site acts as a tenant. It defines:

  • Which apps are installed
  • The database to use
  • Redis and caching settings
  • Email configurations
  • System language
  • Installed modules
  • System-wide settings

Under frappe-bench/sites/, each folder is a site.

Example:

frappe-bench/
└── sites/
├── site1.local/
├── site2.com/
├── common_site_config.json
└── apps.txt

What Does a Frappe Site Contain?

Inside each site folder:

site-name/

├── site_config.json
├── apps.txt
├── private/
├── public/
│ └── files/
├── logs/
├── database.sqlite (if SQLite)
└── .DS_Store (ignored)

Key components

Component Purpose
site_config.json Core site configuration including DB credentials, encryption key, email settings
apps.txt List of installed apps
public/files Public file uploads
private/files Private file uploads
logs/ Request, scheduler, worker logs
database MySQL/MariaDB or SQLite backend data

Frappe automatically reads these directories to determine how the site operates.

Understanding site_config.json (Frappe v15)

This is the most important file in a site:

Example:

{
"db_name": "site1_local",
"db_password": "iB5Hnx39cJfLz8Zr",
"enabled": 1,
"developer_mode": 1,
"encryption_key": "WvCq9r4Gk...=="
}

Common keys

Key Description
db_name Database name
db_password Database user’s password
developer_mode Enables developer mode
encryption_key Encrypts private data
host_name Used for production domain routing
maintenance_mode Used during upgrades

Creating a New Site (Frappe v15)

Use Bench:

bench new-site mysite.local

It will ask you for:

  • MariaDB root password
  • Administrator password

After creation:

  • A new site folder appears under /sites
  • Database is created
  • site_config.json is generated

Installing Apps on a Site

Example:

bench --site mysite.local install-app erpnext

The site now contains all DocTypes and features from ERPNext.

Multi-Site Architecture in Frappe v15

Frappe supports multi-tenancy out of the box.

There are two modes:

1. Port-based multi-site

Each site runs on different ports.
Best for development environments.

2. Host-based multi-site

Each site is mapped to a domain using Nginx.
Best for production deployments.

Mapping domains:

Edit:

sites/site1.com/site_config.json

Add:

"host_name": "https://site1.com"

Then rebuild config:

bench setup nginx
bench restart

Site-Level File Storage

Public Files

Located in:

sites/site-name/public/files/

Accessible via:

/files/<filename>

Private Files

sites/site-name/private/files/

Not accessible publicly.

Generated through:

frappe.utils.file_manager.save_file(...)

Frappe enforces access control before serving private files.

Common Bench Commands for Sites

List sites

bench list-sites

Switch to a site

bench --site mysite.local

Backup a site

bench --site mysite.local backup

Drop a site

bench drop-site mysite.local

Site Lifecycle — How a Site Loads in Frappe

When a request arrives:

  1. Hostname is matched to a site folder
  2. Frappe loads site_config.json
  3. Database connection is created
  4. Installed apps (apps.txt) are loaded
  5. Caches & hooks are initialized
  6. Controllers handle API or UI rendering

This modular loading sequence is what enables complete isolation between tenants.

Cross-References (Recommended Next Steps)

To build full understanding, continue with:

  • Apps in Frappe v15
  • Directory Structure of Frappe
  • How to Create a Site in Frappe
  • DocTypes Overview (v15)
  • Controller Methods
  • Hooks in Frappe v15

Conclusion

Sites are the core of Frappe’s multi-tenant architecture.
They store all business data, configurations, user settings, and runtime state.
By keeping code in apps and data in sites, Frappe ensures:

  • Modular deployments
  • Clean upgrades
  • Multi-company hosting
  • Easy scaling

Understanding how sites work is essential for developing, deploying, and managing ERPNext and custom applications in Frappe Framework Version 15.

 

Click to rate this post!
[Total: 0 Average: 0]