Multi tenant error

Installed ERPNext in a blank Ubuntu server 16.04 using Easy Install script (production). Installation successful but when trying to install multi tenant (https://frappe.github.io/frappe/user/en/bench/guides/setup-multitenancy.html) got the following error after typing “bench new-site tenant1”

Traceback (most recent call last):
File “/usr/local/bin/bench”, line 11, in
load_entry_point(‘bench’, ‘console_scripts’, ‘bench’)()
File “/home/frappe/.bench/bench/cli.py”, line 40, in cli
bench_command()
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 722, in call
return self.main(*args, **kwargs)
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 697, in main
rv = self.invoke(ctx)
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 535, in invoke
return callback(*args, **kwargs)
File “/home/frappe/.bench/bench/commands/config.py”, line 40, in config_dns_multitenant
update_config({‘dns_multitenant’: state})
File “/home/frappe/.bench/bench/config/common_site_config.py”, line 46, in update_config
put_config(config, bench_path=bench_path)
File “/home/frappe/.bench/bench/config/common_site_config.py”, line 40, in put_config
with open(config_path, ‘w’) as f:
IOError: [Errno 2] No such file or directory: ‘./sites/common_site_config.json’

Can you check if the file ‘./sites/common_site_config.json’ (most probably in /home/frappe/frappe-bench/sites/’ is available and accessible by the frappe instance (owner/group frappe) and has a content something like this: (this is from a --production installation)

{
 "auto_update": false, 
 "background_workers": 1, 
 "dns_multitenant": true, 
 "frappe_user": "frappe", 
 "gunicorn_workers": 1, 
 "rebase_on_pull": false, 
 "redis_cache": "redis://localhost:13000", 
 "redis_queue": "redis://localhost:11000", 
 "redis_socketio": "redis://localhost:12000", 
 "restart_supervisor_on_update": true, 
 "serve_default_site": true, 
 "shallow_clone": true, 
 "socketio_port": 9000, 
 "update_bench_on_update": true, 
 "webserver_port": 8000
}

If the file is missing, I propose to create it. If it is there but has odd access values, chown it to frappe.

Hope this helps.

In common_site_config.json I have:

{
“auto_update”: false,
“background_workers”: 1,
“file_watcher_port”: 6787,
“frappe_user”: “frappe”,
“gunicorn_workers”: 2,
“rebase_on_pull”: false,
“redis_cache”: “redis://localhost:13000”,
“redis_queue”: “redis://localhost:11000”,
“redis_socketio”: “redis://localhost:12000”,
“restart_supervisor_on_update”: true,
“serve_default_site”: true,
“shallow_clone”: true,
“socketio_port”: 9000,
“update_bench_on_update”: true,
“webserver_port”: 8000
}

In my installation, I didn’t use the default user “frappe” so does that mean I need to change the line “frappe_user”: “frappe” to my own user?

Was

$ sudo bench config dns_multitenant on

successful?

Can you try and run the command as sudo (or chmod temporarily to allow full write access, revert after applying bench)

sudo bench new-site tenant1

Ok I just did another fresh Ubuntu installation using Easy install script but this time used “python install.py --production --user frappe” so that I have user frappe.

I logged out and login as frappe then Switch off DNS based multitenancy as I will be using Port base but when executing “bench config dns_multitenant off” I get the following error

$ bench config dns_multitenant off
Traceback (most recent call last):
File “/usr/local/bin/bench”, line 11, in
load_entry_point(‘bench’, ‘console_scripts’, ‘bench’)()
File “/home/frappe/.bench/bench/cli.py”, line 40, in cli
bench_command()
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 722, in call
return self.main(*args, **kwargs)
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 697, in main
rv = self.invoke(ctx)
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 535, in invoke
return callback(*args, **kwargs)
File “/home/frappe/.bench/bench/commands/config.py”, line 40, in config_dns_multitenant
update_config({‘dns_multitenant’: state})
File “/home/frappe/.bench/bench/config/common_site_config.py”, line 46, in update_config
put_config(config, bench_path=bench_path)
File “/home/frappe/.bench/bench/config/common_site_config.py”, line 40, in put_config
with open(config_path, ‘w’) as f:
IOError: [Errno 2] No such file or directory: ‘./sites/common_site_config.json’

i looked at frappe-bench/sites and can see common_site_config.json with the following content:

{
“auto_update”: false,
“background_workers”: 1,
“file_watcher_port”: 6787,
“frappe_user”: “frappe”,
“gunicorn_workers”: 2,
“rebase_on_pull”: false,
“redis_cache”: “redis://localhost:13000”,
“redis_queue”: “redis://localhost:11000”,
“redis_socketio”: “redis://localhost:12000”,
“restart_supervisor_on_update”: true,
“serve_default_site”: true,
“shallow_clone”: true,
“socketio_port”: 9000,
“update_bench_on_update”: true,
“webserver_port”: 8000
}

running “sudo bench config dns_multitenant off” or “sudo bench new-site tenant1” gives the message “You should not run this command as root”

From where are you running the bench command? Make sure to be in /home/frappe/frappe-bench to run it (with sudo from any user or with user frappe).

Yes that worked. Thank you so much.