Home Featured Setup ERPNext for Production

Setup ERPNext for Production

by karani

When ERPNext is installed in development mode, you will have to restart the instance with the bench start command every time you want to access it. You can however start your instance when the server boots by setting up your instance for production.

In this article, I will show you a simple way to move your instance from development mode to production mode.

We will be using Supervisor to manage to manage the ERPNext process and Nginx as a reverse proxy to access the ERPNext process without using port 8000.

Process

There are two ways this can be done. I will start with the simple and straightforward one.

Run the below commands from your bench directory:

sudo bench setup production [BENCH USER]
sudo supervisorctl restart all

If you are successful, your instance should be in production mode.

If this didn’t work for you, follow the following steps:

First, change the user to your bench user and install Supervisor and Nginx with the following command:

su - erpnext
sudo apt-get -y install supervisor nginx

Next, install the frappe-bench add-on with the following command:

sudo pip3 install frappe-bench

Next, run the following command to configure ERPNext for a production environment:

sudo /home/erpnext/.local/bin/bench setup production erpnext

You should see the following output:

Site erpnext.example.com assigned port: 80
$ sudo /usr/bin/supervisorctl reread
erpnext-redis: available
erpnext-web: available
erpnext-workers: available
$ sudo /usr/bin/supervisorctl update
erpnext-redis: added process group
erpnext-web: added process group
erpnext-workers: added process group
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
$ sudo systemctl reload nginx

At this point, ERPNext is installed and configured to run on port 80. Now, open your web browser and type in Your URL without the port.

 

You may also like

11 comments

ricamariz March 18, 2022 - 11:59 am

Hi, Karani!

Do you have an answer to the error generated by this code already?

sudo /home/erpnext/.local/bin/bench setup production erpnext

I hope you can share. Thanks!

GoldenScrew October 18, 2021 - 11:44 am

Hi. I have an error:
“sudo: /home/erpnext/.local/bin/bench: command not found”

karani October 18, 2021 - 11:50 am

Make sure you are running bench commands as a bench user

GoldenScrew October 18, 2021 - 12:05 pm

yes it is bench user.

GoldenScrew October 18, 2021 - 12:21 pm

so, what should I do?

benjamin September 28, 2021 - 11:51 am

Hi i want to know more about the site address. should it be a registered domain name ? Thanks

karani September 29, 2021 - 6:32 am

Hello, the site names should be registered and propagation done before they can be accessed.

ridro September 17, 2021 - 12:14 pm

Thanks for the prompt response, i was able to install and run erpenxt with the install guide, but trying to switch to production i am getting errors please help

erpnext@erpnext:~$ sudo /home/erpnext/.local/bin/bench setup production erpnext
sudo: /home/erpnext/.local/bin/bench: command not found
step #3 of this guide.

thanks again

ridro September 17, 2021 - 12:23 pm

i have got to work thanks for this.

karani September 18, 2021 - 5:54 am

Rirdo, you must be getting the path to your bench directory wrong. From your erpnext folder, run .local/bin/bench setup production erpnext

GoldenScrew October 18, 2021 - 12:04 pm

I try it, but doesn’t works.

Please see below:

erpnext@h-98441:~/.local$ cd /
erpnext@h-98441:/$ cd home
erpnext@h-98441:/home$ cd erpnext
erpnext@h-98441:~$ sudo .local/bin/bench setup production erpnext
sudo: .local/bin/bench: command not found
erpnext@h-98441:~$ sudo /.local/bin/bench setup production erpnext
sudo: /.local/bin/bench: command not found
erpnext@h-98441:~$ cd .local
erpnext@h-98441:~/.local$ cd bin
-bash: cd: bin: No such file or directory
erpnext@h-98441:~/.local$ ls
share
erpnext@h-98441:~/.local$ sudo /bin/bench setup production erpnext
sudo: /bin/bench: command not found
erpnext@h-98441:~/.local$

Leave a Comment