Bench Start - Single Site or All Sites in Bench

What happens when following command is run?

$ bench start
  1. Does it serve a single site only?
  2. Installed Bench Manager as a second site on the bench, but its not accessible from host machine using Bench Manager Url. The first site is served.

Guide further.

What does: bench setup nginx report?

In the background, bench start initiates a simple werkzeug server for your default site. If you have other sites on the same host, they will not be served.

I suspect you could run the command more than once in different terminal sessions to serve different sites, but I’ve never tried it. Generally speaking, bench start is intended only for development. For multiple tenants, you would usually set up a production deployment (which includes nginx and supervisorctl).

Edited: Looks like my understanding was incorrect! See @revant_one’s correct answer below

bench start will serve all sites as long as currentsite.txt is not configured.

I create sites like: site1.localhost, site2.localhost, siteN.localhost, I can access them via hostname like: http://siteN.localhost:8000, http://site2.localhost:8000

7 Likes

Thanks, Revant, for your answer. I always follow your contribution to this community.

I have a question regarding this. In development, is it possible to serve more than one site using hostname only? I tried this without luck. I always have to specify the port, for example: site1.com:8000 and site2.com: 8001

How would I configure nginx and Procfile to serve two sites using their hostname and the default http port 80 concurrently?

Hi @Alaa:

Just configure nginx to serve your sites …

You could do it manually or … as a trick … configure production environment for DNS based multisite. It will adjust nginx.conf, create symlinks properly, etc … Then disable production and run bench start.

Hope this helps.

Thank you @avc

Actually, that what I was doing. I have enabled the error logs of nginx and realized that the issue is with the permission. Looks like the command bench setup production sets some special permission for nginx to be able to communicate with the server.

I will try to figure out how to handle the permission for the below error logs from the nginx error log file:

"2024/08/25 09:15:22 [crit] 1199#1199: *8 open() ".../sites/site-one/public//" failed (13: Permission denied), client: *.*.*.*, server: site-one, request: "GET / HTTP/1.1", host: "site-one"
2024/08/25 09:15:22 [error] 1199#1199: *8 connect() failed (111: Connection refused) while connecting to upstream, client: *.*.*.*, server: site-one, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:8000/", host: "site-one"
2024/08/25 09:15:22 [crit] 1199#1199: *8 open() ".../dev-bench/sites/site-one/public//favicon.ico" failed (13: Permission denied), client: *.*.*.*, server: site-one, request: "GET /favicon.ico HTTP/1.1", host: "site-one", referrer: "http://site-one/"
2024/08/25 09:15:22 [error] 1199#1199: *8 connect() failed (111: Connection refused) while connecting to upstream, client: *.*.*.*, server: site-one, request: "GET /favicon.ico HTTP/1.1", upstream: "http://127.0.0.1:8000/favicon.ico", host: "site-one", referrer: "http://site-one/"

If you know how to fix these issues as per the Frappe Framework way, I appreciate your help.

Maybe user permission over assets (css, etc …) … I tried and it works, but let me check permissions.

Thank you dear.

All seems to be working perfectly now.

Set all folder permissions inside the public folder to 775
Set all files permissions inside the public folder to 664

Things are working as expected.

1 Like

最简单的办法是修改Supervisor的配置文件
配置文件位置在/etc/supservisor/conf.d目录下
打开frappe-bench.conf
然后把127.0.0.1 改成 0.0.0.0 后重新加载sueprvisor即可
sudo supervisorctl update
然后就可以使用域名:8000来进行访问指定的Sites