Frappe Framework v15 | Multi Bench Setup
Multi Bench Setup
This tutorial will walk you through the steps for setting up multiple installations of frappe-bench.
For installations using nginx:
A Multi-Bench setup allows you to have multiple codebases and configurations on the same system. Creating a new bench is straightforward, just run:
bench init [bench-name], preferably in your home directory, and let it install its dependencies.
[bench-name] is whatever you want to name your bench installation. The most commonly used is “frappe-bench”. Do not use the brakcets ( [ ] ) once you choose a name.
When you create a new bench, it will automatically use different ports from the existing bench. For example, if you are accessing your site from localhost:8000 on your first bench, then the second bench's port will be set as 8001.
It's important to note that “localhost” is used as a placeholder and most of the instructions you find online assume a person is installing on their local machine which is why most of the instructions default to “localhost”. If you are installing on a public server, this will be your TLD. For example, “domain.com” or "example.com". Alternatively, you could just use your private IP or public IP address assigned to your server. For example, localhost could be 127.0.0.1, domain.com could be 123.4.5.67, etc.
Additionally, you may have a situation where the port number does not change automatically. One example is if you are using a different user for the second installation of frappe-bench. The install script cannot detect an existing installation so all the ports will have to be changed manually. See Changing Ports Manually section below.
The biggest advantage to a multi-bench setup is that you can have different kinds of setups, e.g. Development and Production on the same server. A multi-production, multi-development setup is also fine.
For a production setup, you will have to run bench setup nginx every time after creating a new site. This should change both the ports that frappe-bench is running on and automatically setup nginx to serve those ports.
- If a new site is automatically created in primary bench, then remove file name frappe_bench_dir in /etc/
- If the server port doesn't change from 8000, then change it manually in nginx.conf and supervisor.conf
- For redis, change redis port in /sites/common_site_config.json and run the following commands:
- bench setup socketio
- bench setup redis
- service nginx reload
- supervisorctl reload
- Multi-Bench works easier when setup under one user
For installations using Apache:
There is no built-in feature to change the ports for Apache installations. You must follow the steps below for Changing Ports Manually.
These instructions are only for change frappe-bench ports and will not affect port assignment on your Apache server. You must either use proxy port assignment or route your frappe-bench server to the IP address or domain name you will be serving from Apache.
Changing Ports Manually
Procfile holds the port assignment for frappe-bench after running the bench start command. Port assignment defaults to 8000. You can change this to any other port that will not conflict with another port already being used. For example, port 8001. You will also need to make changes to the Redis conf files as well.
Directory Structure:
.
├── Procfile
├── apps
│ └── frappe
├── config
│ ├── pids
│ ├── redis_cache.conf
│ ├── redis_queue.conf
│ └── redis_socketio.conf
├── env
│ ├── bin
│ ├── include
│ ├── lib
│ └── share
├── logs
│ ├── backup.log
│ └── bench.log
└── sites
├── apps.txt
├── assets
└── common_site_config.json
Sample default Procfile:
redis_cache: redis-server config/redis_cache.conf
redis_queue: redis-server config/redis_queue.conf
web: bench serve --port 8000
socketio: /usr/bin/node apps/frappe/socketio.js
watch: bench watch
schedule: bench schedule
worker: bench worker 1>> logs/worker.log 2>> logs/worker.error.log
Change the default port 13000 to a new port that will not conflict with any other ports already being used. For example, port 13001.
Sample default redis-cache.conf file:
dbfilename redis_cache.rdb
dir /path/to/frappe-bench/config/pids
pidfile /path/to/frappe-bench/config/pids/redis_cache.pid
bind 127.0.0.1
port 13000
maxmemory 1602mb
maxmemory-policy allkeys-lru
appendonly no
save ""
aclfile /path/to/frappe-bench/config/redis_cache.acl
Change the default port 11000 to a new port that will not conflict with any other ports already being used. For example. port 11001.
Sample default redis_queue.conf file:
dbfilename redis_queue.rdb
dir /home/emeraldshield.org/domains/erp.emeraldshield.org/public_html/frappe-bench/config/pids
pidfile /home/emeraldshield.org/domains/erp.emeraldshield.org/public_html/frappe-bench/config/pids/redis_queue.pid
bind 127.0.0.1
port 11000
aclfile /home/emeraldshield.org/domains/erp.emeraldshield.org/public_html/frappe-bench/config/redis_queue.acl