bench setup production command performs a complete production setup, configuring NGINX as a web server and Supervisor or systemd for process management.
Usage
Arguments
System user that will own and run the bench processes.Typically
frappe or your server username.Options
Skip confirmation prompts and automatically regenerate configuration files.
Examples
Basic Production Setup
Set up production environment for userfrappe:
Skip Confirmations
Automatically overwrite existing configuration:What It Does
Install Prerequisites
Installs required system packages:
- Ansible (for automation)
- fail2ban (intrusion prevention)
- NGINX (web server)
- Supervisor (process manager)
Detect Process Manager
Checks
common_site_config.json for:restart_supervisor_on_update: Use Supervisorrestart_systemd_on_update: Use systemd
Configure Process Manager
Generates and installs configuration for either:
- Supervisor configuration in
/etc/supervisor/conf.d/ - systemd service files in
/etc/systemd/system/
Remove Default Configs
Removes default NGINX configurations that might conflict:
/etc/nginx/conf.d/default.conf/etc/nginx/sites-enabled/default
Configuration Files Created
Supervisor Mode
systemd Mode
NGINX
Process Management
Supervisor (Default)
Manage bench processes with supervisorctl:systemd
To use systemd instead of Supervisor, set incommon_site_config.json:
Prerequisites
System Requirements
- Ubuntu 20.04+ or Debian 10+
- Sudo access
- Python 3 with pip
- At least 2GB RAM (4GB recommended)
Bench Requirements
- Fully initialized bench with at least one site
- All apps installed and working
- DNS configured (for multi-tenant setups)
DNS Configuration
Single Site
For a single site on a dedicated server:Multi-Tenant
For multiple sites with different domains:Post-Setup Steps
Troubleshooting
Permission Errors
If you see permission denied errors:NGINX Test Failed
If NGINX configuration test fails:Services Not Starting
For Supervisor:Port Already in Use
If port 80 or other ports are in use:Security Considerations
File Permissions
Production setup ensures:- Bench files owned by specified user
- Proper read/write/execute permissions
- Web-facing directories not world-writable
fail2ban
The setup installs fail2ban for intrusion prevention. Configure additional jails:Firewall
Set up a firewall to allow only necessary ports:Related Commands
bench setup nginx- Configure only NGINXbench setup supervisor- Configure only Supervisorbench setup lets-encrypt- Add SSL certificatesbench setup backups- Schedule backups
Source Code
Implementation:bench/config/production_setup.py:35
Command definition: bench/commands/setup.py:103