Guide: Manual Install ERPNext on Ubuntu 17.xx & 18.xx

Setup Supervisor & Nginx for Production

By default, the ERPNext application listens on port 8000, not the standard HTTP port 80. Also, running the built in web server for production use is not recommended as we will be exposing the server to the world. You should use a production web server as a reverse proxy such as Apache or Nginx. We will use Nginx as a reverse proxy as it can be automatically configured using Bench. Bench can automatically generate and install the configuration according to the ERPNext setup.

Although we can start the application using the ‘bench start’ command, the execution of ERPNext will stop as soon as you close the terminal. To overcome this issue, you should use Supervisor, which is very helpful in running the application continuously in a production environment. Supervisor is a process control system that enables you to monitor and control a number of processes on Linux operating systems. Once Supervisor is configured, it will automatically start the application at boot time as well as on failures. Bench can automatically configure Supervisor for the ERPNext application.

Install Supervisor.

sudo apt -y install supervisor

Start Supervisor and enable it to automatically start at boot time.

sudo systemctl start supervisor
sudo systemctl enable supervisor

Setup Bench for production use.

sudo bench setup production bench

The above command may prompt you before replacing the existing Supervisor default configuration file with a new one. Choose y to proceed. Bench adds a number of processes to the Supervisor configuration file. The above command will also ask you if you wish to replace the current Nginx configuration with a new one. Enter y to proceed. Once Bench has finished installing the configuration, provide other users to execute the files in your home directory of the Bench user.

chmod o+x /opt/bench/

You can now access the site on http://erp.example.com.

You can check the status of the processes by running.

sudo supervisorctl status all

You should see the following output.

sudo supervisorctl status all
erpnext-redis:erpnext-redis-cache                 RUNNING   pid 13852, uptime 0:00:54
erpnext-redis:erpnext-redis-queue                 RUNNING   pid 13851, uptime 0:00:54
erpnext-redis:erpnext-redis-socketio              RUNNING   pid 13853, uptime 0:00:54
erpnext-web:erpnext-frappe-web                    RUNNING   pid 13856, uptime 0:00:54
erpnext-web:erpnext-node-socketio                 RUNNING   pid 13855, uptime 0:00:54
erpnext-workers:erpnext-frappe-default-worker-0   RUNNING   pid 13862, uptime 0:00:54
erpnext-workers:erpnext-frappe-long-worker-0      RUNNING   pid 13870, uptime 0:00:54
erpnext-workers:erpnext-frappe-schedule           RUNNING   pid 13869, uptime 0:00:54
erpnext-workers:erpnext-frappe-short-worker-0     RUNNING   pid 13875, uptime 0:00:54

To stop and Start all of the ERPNext processes.

sudo supervisorctl stop all
sudo supervisorctl start all
1 Like