ERPNext from installation to multi-tenancy configuration on Ubuntu 18/CentOs 7

I tested the process in ubuntu 18 & centos 7, I wanted to share if anyone need.

1. Install python-minimal
apt-get install python-minimal

2. Install some dependencies
apt-get install build-essential python-setuptools

3. Download the script
wget https://raw.githubusercontent.com/frappe/bench/master/playbooks/install.py

4. Create a new user & add to sudoer group
adduser frappe
usermod -aG sudo frappe

5. Run the script
sudo python install.py --production --user frappe

if your installation failed please retry for second time will pass.

6. Change site1.local to your company name
[frappe@erpnext ~]$ cd frappe-bench
[frappe@erpnext frappe-bench]$ mv sites/site1.local sites/erp.example1.com

7. Create 2 more sites
bench new-site erp.example2.com
bench new-site erp.example3.com

8. Install application to your specific sites
bench --site erp.example2.com install-app erpnext
bench --site erp.example3.com install-app erpnext

Setup DNS based multitenancy

9. Enable multitenancy mode
[frappe@erpnext frappe-bench]$ bench config dns_multitenant on

10. Setup domains
[frappe@erpnext frappe-bench]$ bench setup add-domain erp.example1.com --site erp.example1.com
[frappe@erpnext frappe-bench]$ bench setup add-domain erp.example2.com --site erp.example2.com
[frappe@erpnext frappe-bench]$ bench setup add-domain erp.example3.com --site erp.example3.com

11. Edit your host file & assign your ip to your domain name
[frappe@erpnext frappe-bench]$ sudo vim /etc/hosts

host file looks like this
127.0.0.1 localhost
192.168.1.15 erp.mediamark.com
192.168.1.15 erp.shahrmedia.com
192.168.1.15 erp.techmark.com

12. Regenerate nginx config & restart
[frappe@erpnext frappe-bench]$ bench setup nginx
[frappe@erpnext frappe-bench]$ sudo service nginx restart

13. Now in your browser you can access each site by their domain name like erp.example1.com, erp.example2.com & erp.example3.com, the ip address wouldn’t work once multitenant is enabled.

Thats all. :stuck_out_tongue_winking_eye:

10 Likes

Do you need to update the host file records for every new site created?

I did, but it might work too if u don’t add each one.

1 Like

Im using windows how do i go about this. where do i input all the above

Hello and welcome allanball1

I am not a Windows user but maybe install Ubuntu 16 with these notes Install WSL | Microsoft Learn

Then try the easy install method GitHub - frappe/bench: CLI to manage Multi-tenant deployments for Frappe apps

We all get stuck but this forum is full of pointers if you need clues

it keeps telling me connection refused. im using puTTY

My guess is you are trying to run a network connection from Windows to Ubuntu.

Your problem is on the Ubuntu end, either

  1. the ssh service is not running or listening on the IP:Port you are trying to connect to, 2. the port is blocked by a firewall.

A web search like ‘windows putty ssh connection refused’ will advise you how to troubleshoot.

good job, could you please explain how to use those domains from client machines.

If you have already started adding data to site 1 and follow these directions, is that safe?

I have installed for a multicompany environment, as I start to get setup I have realized the need for multi-tenancy. Can I follow this to safely add companies 2 and 3?

I have setup site 1 and using it with good amount of data in it.

Now, want to add another site using multi tenancy.

Is it fine to add add more sites now?
with data exists on site 1?

I tried it but wont work

I dont know the answer to this one. But maybe you can try to back up your DB and test the dump on a test server, by creating a second site there

Hi @zia ,
I have executed the multitenant setup commands and the IP address only working for me. The respective sitename.com is not working.
Could you please assist me to fix this issue?