How to Install ERPNext on Ubuntu 22.04

ERPNext is a free and open-source ERP software used by manufacturers, distributors, and services. It is built with Python, JavaScript, and Frappe Framework. It is modern, easy-to-use, free, and designed for small and medium-sized businesses that help companies manage all aspects of their business operations. Thousands of businesses worldwide use it to manage their ERP processes. It is one of the best ERP systems that supports manufacturing, distribution, retail, trading, services, education, nonprofits, and more.

In this tutorial, we will show you how to install the ERPNext software on Ubuntu 22.04 server.

Prerequisites

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

Getting Started

First, you will need to install some Python dependencies on 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 python3.10-venv -y

Once all the Python dependencies are installed, you will need to install Node.js on your server.

First, add the Node.js repository with the following command:

curl -sL https://deb.nodesource.com/setup_16.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 22.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, 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

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

systemctl restart mariadb

Install ERPNext on Ubuntu 22.04

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 the ERPNext user and setup the 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

Next, create a directory for ERPNext with the following command:

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

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

cd /opt/bench/erpnext
bench new-site erp.example.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.example.com

At this point, ERPNext is installed in your system.

Configure ERPNext for the Production Environment

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

First, switch the user to ERPNext then 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.example.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 the production environment.

Access ERPNext Web UI

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

ERPNext Login

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

Select language

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

Create a user

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

ERPNext Dashboard

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.example.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.example.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 complete 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.example.com

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

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/erp.example.com/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/erp.example.com/privkey.pem
   Your cert will expire on 2022-09-11. 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

Congratulations! you have successfully installed ERPNext with Nginx and Let's Encrypt SSL on Ubuntu 22.04. Feel free to ask me if you have any questions. You can visit the ERPNext documentation page for more information.

Share this page:

2 Comment(s)