Introduction
In this guide, we will delve into the Site Management feature of Empress. This feature is a significant part of the Empress framework, allowing developers to manage and customize databases associated with each site, install Apps, and handle the site directory structure.
Getting Started
Every site in Empress comes with a database which can be customized through site-specific scripting. Apps may also be installed for added functionalities. To get started, let’s create a new site.
Creating a New Site
To create a new site, run the following command from the frappe-bench directory:
$ bench new-site library.test
This command creates a new database, so you need to enter your MySQL root password. It will also prompt you to set the password for the Administrator user. Set a password that you can remember easily as it will be useful later on.
Upon successful execution, you will have a new folder named library.test in the sites directory.
Understanding Site Directory Structure
The site directory structure will look something like this:
sites/library.test
├── indexes
│ └── web_routes
├── locks
├── logs
├── private
│ ├── backups
│ └── files
├── public
│ └── files
└── site_config.json
Here’s what each directory and file does:
- indexes: Contains indexes generated via Website Search.
- locks: Maintains file-based locks over in-site documents and indicators of the site’s state.
- private: Contains database backups and private files that need authentication to be accessible.
- public: Contains files that are accessible without authentication, like website images.
- site_config.json: Contains site-specific configuration that should not be version controlled.
An example of the site_config.json file is shown below:
{
"db_name": "_ad03fa1a016ca1c4",
"db_password": "pz1d2gN5y35ydRO5",
"db_type": "mariadb"
}
Accessing the Site in Your Browser
To access your site in the browser, you need to map the site name to localhost. To do this, add the following entry to your /etc/hosts file:
127.0.0.1 library.test
Alternatively, you can use the bench command:
$ bench --site library.test add-to-hosts
Now, you should be able to access your site at http://library.test:8000.
Installing an App on the Site
To install an App on your site, run the following command:
$ bench --site library.test install-app library_management
To confirm if the app was installed, run:
$ bench --site library.test list-apps
You should see frappe and library_management as installed apps on your site.
Logging into the Desk
To create DocTypes in our app, we must log in to the Desk at http://library.test:8000. Enter Administrator as the user and the password you set while creating the site.
After successful login, you will see the setup wizard. This is a one-time setup wizard used to set up localization details for your site.
Site Commands
Here are some of the useful site commands:
- Python Console:
$ bench --site library.test console - MariaDB Console:
$ bench --site library.test mariadb - Database Backup:
$ bench --site library.test backup
Summary
The Site Management feature in Empress offers a powerful way for developers to manage databases, install apps, and handle the site directory structure. With this feature, developers can effectively integrate and customize these elements for various business solutions. The ability to create, modify, and debug each site separately enhances the flexibility and efficiency of software development in Empress.