There is a new version of this tutorial available for Ubuntu 22.04 (Jammy Jellyfish).

How to install ERPNext on Ubuntu 20.04 LTS

ERPNext is a free and open-source ERP software built with Python, JavaScript, and Frappe Framework. It is a modern, easy-to-use, free business system used by manufacturers, distributors, and services. It is designed for small and medium-sized businesses that help companies manage all aspects of their business operations. It is one of the best open-source ERP management software used by thousands of businesses worldwide to manage their ERP processes.

In this tutorial, I will explain how to install ERPNext on Ubuntu 20.04 server.

Prerequisites

  • A server running Ubuntu 20.04.
  • A valid domain is pointed with your server.
  • A root password is configured on your server.

Getting Started

Before starting, you will need to install required Python dependencies in your system. You can install all of them with the following command:

apt-get install python3-dev libffi-dev git python3-pip python3-testresources libssl-dev wkhtmltopdf gcc g++ make -y

After installing Python dependencies, ERPNext also uses Node.js for its frontend. So add the Node.js repository with the following command:

curl -sL https://deb.nodesource.com/setup_12.x | bash -

Next, install Node.js and Redis server with the following command:

apt-get install nodejs redis-server -y

Once both packages are installed, install the Yarn package by running the following command:

npm install -g yarn

Once you are finished, you can proceed to the next step.

Install and Configure MariaDB Database

By default, MariaDB is available in the Ubuntu 20.04 default repository. You can install it with the following command:

apt-get install mariadb-server -y

Once installed, secure the MariaDB and set the MariaDB root password with the following command:

mysql_secure_installation

Answer all the questions as shown below to set the MariaDB root password and secure the installation:

Enter current password for root (enter for none):
Set root password? [Y/n] Y
New password:
Re-enter new password:
Remove anonymous users? [Y/n] Y
Disallow root login remotely? [Y/n] Y
Remove test database and access to it? [Y/n] Y
Reload privilege tables now? [Y/n] Y

Once the MariaDB is secured, log in to the MariaDB console with the following command:

mysql -u root -p

Next, change the MariaDB authentication plugin with the following command:

MariaDB [(none)]>USE mysql;
MariaDB [(none)]>UPDATE user SET plugin='mysql_native_password' WHERE User='root';

Next, flush the privileges and exit from the MariaDB shell with the following command:

MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> EXIT;

Next, you will need to change MariaDB Innodb fileformat to Barracuda. You can do it by editing the file /etc/mysql/mariadb.conf.d/50-server.cnf:

nano /etc/mysql/mariadb.conf.d/50-server.cnf

Add / Modify the following lines:

[mysqld]
innodb-file-format=barracuda
innodb-file-per-table=1
innodb-large-prefix=1
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci

[mysql]
default-character-set = utf8mb4

Save and close the file then restart the MariaDB service to implement the changes:

systemctl restart mariadb

Install ERPNext

In this section, we will show you how to create ERPNext user, install bench tool and install ERPNext in your system.

Create ERPNext User

First, create a new user to run the ERPNext using the following command:

useradd -m -s /bin/bash erpnext

Next, set the password for ERPNext with the following command:

passwd erpnext

Next, add the ERPNext user to the sudo group with the following command:

usermod -aG sudo erpnext

Next, log in to ERPNext user and setup environment variable with the following command:

su - erpnext
nano ~/.bashrc

Add the following line:

PATH=$PATH:~/.local/bin/

Save the file then activate the environment variable with the following command:

source ~/.bashrc

Install Bench Tool

First, switch the directory to ERPNext user and create a directory for ERPNext with the following command:

su - erpnext
sudo mkdir /opt/bench

Next, set the ownership to the erpnext user:

sudo chown -R erpnext:erpnext /opt/bench

Next, change the directory to /opt/bench and clone the bench repository from Git Hub:

cd /opt/bench
git clone https://github.com/frappe/bench bench-repo

Next, install the bench repo using the pip3 command:

pip3 install -e bench-repo

Once installed, initialize the bench directory with frappe framework using the following command:

bench init erpnext

You should get the following output:

? Built js/checkout.min.js
? Built js/dialog.min.js
? Built js/social.min.js
? Built js/web_form.min.js
? Built js/list.min.js
? Built js/chat.js
Browserslist: caniuse-lite is outdated. Please run next command `yarn upgrade caniuse-lite browserslist`
? Built css/frappe-rtl.css
? Built css/printview.css
? Built js/bootstrap-4-web.min.js
? Built js/barcode_scanner.min.js
? Built css/list.min.css
? Built css/report.min.css
? Built frappe/css/email.css
? Built js/frappe-recorder.min.js
? Built js/desk.min.js
? Built css/frappe-chat-web.css
? Built js/frappe-web.min.js
? Built css/form.min.css
? Built css/web_form.css
? Built css/desk.min.css
? Built css/frappe-web-b4.css
? Built js/control.min.js
? Built js/form.min.js
? Built js/data_import_tools.min.js
? Built js/report.min.js
?  Done in 111.35s
Done in 113.33s.
SUCCESS: Bench erpnext initialized

Create ERPNext Site

Next, change the directory to erpnext and create a new ERPNext site with the following command:

cd /opt/bench/erpnext
bench new-site erp.linuxbuz.com

You will be asked to provide your MariaDB root password and Administrator password as shown below:

MySQL root password: 

Installing frappe...
Updating DocTypes for frappe        : [========================================] 100%
Updating country info               : [========================================] 100%
Set Administrator password: 
Re-enter Administrator password: 
*** Scheduler is disabled ***
Current Site set to erp.linuxbuz.com

At this point, ERPNext is installed in your system.

Configure ERPNext for Production Environment

Next, you will need to install Supervisor to manage the ERPNext process and Nginx as a reverse proxy.

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

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

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

sudo pip3 install frappe-bench

Next, change the directory to /opt/bench/erpnext and setup ERPNext for production environment with the following command:

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

Once the ERPNext is configured, you should see the following output:

PLAY RECAP ************************************************************************************************************************************
localhost                  : ok=8    changed=4    unreachable=0    failed=0    skipped=1    rescued=0    ignored=0   

$ sudo systemctl restart supervisor
Port configuration list:

Site erp.linuxbuz.com assigned port: 80
$ /usr/bin/supervisorctl reread
No config updates to processes
$ /usr/bin/supervisorctl update
$ sudo /usr/sbin/nginx -t
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 configured with Nginx for production environment.

Access ERPNext Web UI

Now, open your web browser and type the URL http://erp.linuxbuz.com. You will be redirected to the ERPNext login page:

Provide the username as Administrator and a password which you have set earlier and click on the Login button. You should see the following page:

Select your desired language and click on the Next button. You should see the following page:

Select your Country, Time Zone, Currency and click on the Next button. You should see the following page:

Provide your name, email, password and click on the Complete Setup button. You should see the ERPNext dashboard in the following page:

Secure ERPNext with Let's Encrypt SSL

First, you will need to install the Certbot client to install and manage the Let's Encrypt SSL. You can install it with the following command:

sudo apt-get install certbot python3-certbot-nginx -y

Once installed, run the following command to install and configure Let's Encrypt SSL for your domain:

sudo certbot --nginx -d erp.linuxbuz.com

You will be asked to provide your email and accept the term of service as shown below:

Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator nginx, Installer nginx
Enter email address (used for urgent renewal and security notices) (Enter 'c' to
cancel): [email protected]

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must
agree in order to register with the ACME server at
https://acme-v02.api.letsencrypt.org/directory
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(A)gree/(C)ancel: A

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing to share your email address with the Electronic Frontier
Foundation, a founding partner of the Let's Encrypt project and the non-profit
organization that develops Certbot? We'd like to send you email about our work
encrypting the web, EFF news, campaigns, and ways to support digital freedom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: Y
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for erp.linuxbuz.com
Waiting for verification...
Cleaning up challenges
Deploying Certificate to VirtualHost /etc/nginx/conf.d/erpnext.conf

Next, select whether or not to redirect HTTP traffic to HTTPS as shown below:

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: No redirect - Make no further changes to the webserver configuration.
2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for
new sites, or if you're confident your site works on HTTPS. You can undo this
change by editing your web server's configuration.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2

Type 2 and hit Enter to completed the process. You should see the following output:

Redirecting all traffic on port 80 to ssl in /etc/nginx/conf.d/erpnext.conf

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations! You have successfully enabled https://erp.linuxbuz.com

You should test your configuration at:
https://www.ssllabs.com/ssltest/analyze.html?d=erp.linuxbuz.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/erp.linuxbuz.com/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/erp.linuxbuz.com/privkey.pem
   Your cert will expire on 2020-08-29. To obtain a new or tweaked
   version of this certificate in the future, simply run certbot again
   with the "certonly" option. To non-interactively renew *all* of
   your certificates, run "certbot renew"
 - Your account credentials have been saved in your Certbot
   configuration directory at /etc/letsencrypt. You should make a
   secure backup of this folder now. This configuration directory will
   also contain certificates and private keys obtained by Certbot so
   making regular backups of this folder is ideal.
 - If you like Certbot, please consider supporting our work by:

   Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
   Donating to EFF:                    https://eff.org/donate-le

 - We were unable to subscribe you the EFF mailing list because your
   e-mail address appears to be invalid. You can try again later by
   visiting https://act.eff.org.

At this point, your ERPNext website is secured with Let's Encrypt SSL. You can now access your website securely with HTTPS protocol.

Conclusion

In this guide, we learned how to install ERPNext with Nginx on Ubuntu 20.04. We also learned how to secure ERPNext with Let's Encrypt SSL. You can visit the ERPNext documentation page for more information.

Share this page:

0 Comment(s)