Multi site setup on bench

Continuing the discussion from ERPNext 4 Installation Problem:

run service nginx reload as root

Here’s the bench way to do dns multitenant,

# rename site1.local and site2.local as site1.example.com and site2.example.com
# Add DNS record for *.example.com to resolve to your server
bench config dns_multitenant on
bench setup nginx
sudo service nginx reload # or run this as root

Now Frappe will serve site as per the domain name resolved.

run service nginx reload as root

Yes, this worked.

rename site1.local and site2.local as site1.example.com and site2.example.com

Is it just renaming the directories under ~/frappe-bench/sites?

bench set-nginx-port site2.local 82

Btw, how can this be redone?

Yes :smile:

You can run it any number of times. Just call bench setup nginx to re generate the config. And reload nginx after that, ofcourse.

But the mySQL databases are still named site.local …

That is fine. Database name doesn’t matter to nginx.

I tried to follow these setps, but my second site is not visible.
I have my server in Digital Ocean and have frappe 4.5
I can access my first site at http://178.62.219.188:8000/
But I cannot access my second site http://178.62.219.188:8082

after executing > frappe@ERPTesting:~/frappe-bench$ bench set-nginx-port malnadtesting.in 82

I did not do DNS configuration as I have not assigned any DNS for this, yet.

@pdvyas can you please look guide me on this ?

I think you’re accessing the site by running bench start

You will have to setup your bench for production (ie setup nginx and supervisor)

@pdvyas I have both supervisor and nginx setup, but I prefer starting by “bench start” command.

Below is the nginx config

Supervisor config

frappe-bench sites folder

http://imgur.com/weRkFoV

I got it working with these instructions, but I have tow subdomains and the DNS records set up as well.

su frappe
cd ~/frappe-bench
bench set-default-site <SITENAME-01>.<DOMAIN>
bench config dns_multitenant on
bench new-site <SITENAME-02>.<DOMAIN>
bench frappe --install_app erpnext <SITENAME-02>.<DOMAIN>
bench setup nginx
su root
cd ~
service nginx reload

Cool, it worked! Thanks!

You don’t need to run bench start if you’ve setup supervisor (they both clash).

@peterschmidler Ok, I will try setting up sub-domains in DO and update the results.

@pdvyas bench start has been my habit, but I will stop using it and see it works on nginx

I am trying to run the erp in multiple subdomain. Followed the Multitenant Setup. But it is not working. I am using CentOs 7.

If I use
bench new-site site2.example.com

It gives errors.

But if I try
bench new-site site2.local

It does not give any error.

But how can I point site2.example.com to site2.local?

you can rename the site,

cd sites
mv site2.local site2.example.com
cd ..
bench setup nginx
sudo service nginx reload

I have tried to setup multi-tenant, but can’t get it to work. The domain erp.teknify.com fails to load. Here is my (generated) nginx file:

http://dpaste.com/1DY5FX7

% host erp.teknify.com
Host erp.teknify.com not found: 3(NXDOMAIN)

Have you added A record in DNS settings?

Yes, that was it. Many thanks!

I am trying to get erpnext up and running on AWS EC2. I am stuck at the new.site1…which A Record should I change? And to what?