Skip to main content

bench new-site

The bench new-site command creates a new Frappe site within the current Bench. It creates a site directory, initializes a new database, installs the Frappe framework, and generates the required site configuration files.

Tip:

Every site created with this command is stored inside the sites directory and has its own database, configuration, and uploaded files.

Command Syntax

bench new-site [OPTIONS] SITE

What the Command Does

When executed, the command performs the following tasks:

  1. Creates a new site directory inside ./sites.
  2. Creates a new MariaDB or PostgreSQL database.
  3. Creates the required database user.
  4. Installs all Frappe modules and DocTypes.
  5. Generates the site_config.json configuration file.

If site creation fails, Bench offers to roll back the changes by removing the site directory, database, and database user.

Site Configuration

Each site contains a configuration file located at:

sites/{site}/site_config.json

This file stores important information such as database credentials, installed applications, and other site-specific settings.

Command Options

Option Description
--db-name Specify the database name.
--db-user Specify a database user or use an existing database user.
--db-password Specify the database user’s password.
--db-type Choose the database type (mariadb or postgres).
--db-host Specify the database server host.
--db-port Specify the database server port.
--db-root-username Specify the MariaDB or PostgreSQL administrator username.
--db-root-password Specify the administrator password for the database server.
--admin-password Set the Frappe Administrator password.
--source_sql Initialize the database using a SQL file.
--install-app Install an application immediately after creating the site.

Available Flags

  • --no-mariadb-socket — Connect to MariaDB using TCP/IP instead of the UNIX socket.
  • --verbose — Display detailed output during execution.
  • --force — Overwrite an existing site or database with the same name.

Examples

1. Create a New Site

bench new-site mysite.local

2. Create a PostgreSQL Site

bench new-site mysite.local --db-type postgres

3. Skip Interactive Password Prompts

bench new-site mysite.local \
    --admin-password admin123 \
    --db-root-password rootpassword

4. Specify Custom Database Configuration

bench new-site mysite.local \
    --db-type postgres \
    --db-name mydatabase \
    --db-user myuser \
    --db-password mypassword \
    --db-host localhost \
    --db-port 5432

5. Use a Non-root Database User

bench new-site mysite.local \
    --db-root-username dbadmin \
    --db-root-password adminpassword

6. Create a Site and Install an App

bench new-site mysite.local --install-app erpnext
Best Practice:

Use the --install-app option when setting up a new environment to automatically install required applications immediately after site creation, reducing manual setup steps.

Rating: 0 / 5 (0 votes)