A streamlined bash script for setting up Frappe Framework with automated bench creation, site deployment, and production configuration.
- Complete System Setup: Automated installation of all dependencies
- Smart Environment Detection: Separate configurations for development and production
- Automated Theme Installation: Installs Frappe Desk Theme automatically
- Custom App Creation: Built-in support for creating and deploying custom Frappe apps
- Production Ready: Full production setup with Supervisor, Nginx, SSL, and proper file permissions
- Assets 404 Fix: Resolves common assets serving issues in production
- Git Integration: Automatic Git repository setup for custom apps
- OS: Ubuntu 20.04+ / Debian 11+
- User: Non-root user with sudo privileges
- Memory: Minimum 2GB RAM (4GB+ recommended for production)
- Storage: At least 10GB free space
# Make executable
chmod +x frappe_enhanced_setup.sh
# Run the script
./frappe_enhanced_setup.sh
1) Complete Setup (System Dependencies + MySQL + SSH/Git)
This installs:
- System packages (Python, Node.js, MariaDB, Redis, etc.)
- wkhtmltopdf for PDF generation
- MySQL/MariaDB with secure configuration
- SSH keys for Git repositories
- Python virtual environment with frappe-bench
2) Create Bench
- Creates a new Frappe bench with specified version
- Default version:
version-15
- Customizable bench name
3) Create Site
- Creates a new Frappe site
- Installs Frappe Desk Theme automatically
- Optional custom app creation with Git integration
- Choose between Development or Production environment
The script automatically installs these dependencies:
System Packages:
- Python 3.8+ with dev tools
- Node.js 18+ and Yarn
- MariaDB server and client
- Redis server
- Nginx web server
- Supervisor process manager
- Let's Encrypt certbot
- wkhtmltopdf for PDF generation
Python Packages:
- frappe-bench
- Required Python libraries
# Features:
- Local development server
- Debug mode enabled
- No SSL/production optimizations
- Direct bench commands
# Usage:
bench start # Start development server
bench --site sitename serve # Serve specific site
# Features:
- Supervisor process management
- Nginx reverse proxy
- SSL certificate (Let's Encrypt)
- Optimized file permissions
- Assets caching and compression
- Security headers
~/frappe_portable/
βββ venv/ # Python virtual environment
βββ your-bench-name/
β βββ apps/ # Frappe applications
β β βββ frappe/ # Core Frappe framework
β β βββ frappe_desk_theme/ # Automated theme installation
β β βββ your-custom-app/ # Your custom applications
β βββ sites/ # Site configurations
β β βββ assets/ # Static assets (CSS, JS, images)
β β βββ your-site/ # Individual site data
β βββ config/ # Nginx and Supervisor configs
- Automated secure installation
- Root password setup
- Database user creation for each site
- Proper charset and collation settings
# Assets serving with proper caching
location /assets {
alias /path/to/bench/sites/assets;
expires 1y;
add_header Cache-Control "public, immutable";
access_log off;
}
# Security headers
add_header X-Frame-Options "SAMEORIGIN";
add_header X-Content-Type-Options "nosniff";
# Proper ownership
chown -R user:www-data sites/
chmod -R 755 sites/
find sites/ -type f -exec chmod 644 {} \;
- Repository: https://github.com/dhwani-ris/frappe_desk_theme
- Installation: Automatic after site creation
- Features: Enhanced UI/UX for Frappe
- App Generation: Uses
bench new-app
command - Installation: Automatically installs on the created site
- Git Integration:
- Initializes Git repository
- Creates initial commit
- Pushes to remote repository (if provided)
# Requirements:
1. Domain pointing to server IP
2. Ports 80 and 443 open
3. Valid DNS resolution
# The script automatically:
- Validates domain DNS
- Installs SSL certificate
- Configures HTTPS redirects
- Updates Nginx configuration
# The script automatically fixes this by:
- Setting correct nginx alias path
- Proper file permissions
- Building assets after installation
# Ensure MySQL is running
sudo systemctl status mariadb
# Reset MySQL password if needed
sudo mysql_secure_installation
# Fix file permissions
sudo chown -R $USER:www-data ~/frappe_portable/
chmod -R 755 ~/frappe_portable/
# Test nginx config
sudo nginx -t
# Check error logs
sudo tail -f /var/log/nginx/error.log
# Check site configuration
bench --site sitename set-config force_https 1
# Clear cache
bench clear-cache
bench clear-website-cache
# Nginx logs
/var/log/nginx/access.log
/var/log/nginx/error.log
# Supervisor logs
/var/log/supervisor/
# Frappe logs
~/frappe_portable/bench-name/logs/
# Activate virtual environment
source ~/frappe_portable/venv/bin/activate
# Navigate to bench
cd ~/frappe_portable/your-bench-name
# Site operations
bench new-site sitename
bench drop-site sitename
bench backup --site sitename
bench restore backup_file --site sitename
# App operations
bench get-app app_repo_url
bench install-app appname --site sitename
bench uninstall-app appname --site sitename
# Updates
bench update --reset
bench migrate
# Production management
sudo supervisorctl restart all
sudo systemctl reload nginx
# Start development server
bench start
# Enable developer mode
bench set-config developer_mode 1
bench clear-cache
# Watch for changes
bench watch
# Add custom domain
bench setup add-domain --site sitename custom-domain.com
# Update site config
bench config dns_multitenant on
# Setup automated backups
bench setup backup-cron --site sitename
# Enable production optimizations
bench setup production
bench config set-common-config enable_scheduler 1
Feel free to submit issues and enhancement requests!
This script is provided as-is under the MIT License.
Powered by Dhwani RIS