How to Install Erpnext on Ubuntu 22.04

ERPNext is a free and open-source integrated Enterprise Resource Planning software developed by an Indian software company Frappe Technologies Pvt. Ltd. and is built on MariaDB database system using Frappe, a Python based server-side framework.

Prerequisites

  • Ubuntu 22.04 VPS with at least 4GB of RAM and 40GB Disk
  • root access or a user with sudo privileges
  • A qualified domain or subdomain name

Update the System

Before starting update all Ubuntu 22.04 packages installed on the server are up to date using below command,

apt update -y 

apt upgrade -y

Create New User

Create a new Frappe Bench User for our ERPNext installation,

sudo adduser (New-Frappe-User)

usermod -aG sudo (New-Frappe-User)

su (New-Frappe-User)

cd /home/(New-Frappe-User)

Replace (New-Frappe-User) with the actual username

Install Dependencies

Install required packages using below command,

Install GIT,

sudo apt-get install git

Install Python3.10, as ERPNext version 14 requires Python 3.10+ version,

sudo apt-get install python3-dev python3.10-dev python3-setuptools python3-pip python3-distutils

Install virtual environment to manage software at one place,

sudo apt-get install python3.10-venv

Install Software Properties Common,

sudo apt-get install software-properties-common

Install MariaDB,

sudo apt install mariadb-server mariadb-client

Install Redis Server,

sudo apt-get install redis-server

Open redis.conf file and change the redis port to 11000,

nano /etc/redis/redis.conf

port 11000

Save the configuration file and restart the redis server using below command,

systemctl restart redis

Install Other Required Packages using below command,

sudo apt-get install xvfb libfontconfig wkhtmltopdf

sudo apt-get install libmysqlclient-dev

Configure MYSQL Server

sudo mysql_secure_installation

Output:

Enter current password for root (enter for none): Press your [Enter] key, there is no password set by default

Switch to unix_socket authentication N

Set root password? [Y/n] Y

New password: Enter_Your_Password

Re-enter new password: Enter_Your_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

Edit MYSQL default config file,

sudo nano /etc/mysql/my.cnf

Add the following to the file,

[mysqld]
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci

[mysql]
default-character-set = utf8mb4

Restart the MYSQL Server using below command,

sudo service mysql restart

Install CURL, Node, NPM and Yarn

Install CURL,

sudo apt install curl

Install Node 16.15.0,

curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash

source ~/.profile

nvm install 16.15.0

Output:

erpnext@vps:~$ nvm install 16.15.0
Downloading and installing node v16.15.0...
Downloading https://nodejs.org/dist/v16.15.0/node-v16.15.0-linux-x64.tar.xz...
################################################################################################################################# 100.0%
Computing checksum with sha256sum
Checksums matched!
Now using node v16.15.0 (npm v8.5.5)
Creating default alias: default -> 16.15.0 (-> v16.15.0)

Install NPM,

sudo apt-get install npm

Install Yarn,

sudo npm install -g yarn

Install Frappe Bench,

sudo pip3 install frappe-bench

Initialize Frappe Bench,

bench init --frappe-branch version-14 frappe-bench

Output:

erpnext@vps:~$ bench init --frappe-branch version-14 frappe-bench
Setting Up Environment
$ python3 -m venv env
$ /home/erpnext/frappe-bench/env/bin/python -m pip install --quiet --upgrade pip
$ /home/erpnext/frappe-bench/env/bin/python -m pip install --quiet wheel
Getting frappe
$ git clone https://github.com/frappe/frappe.git --branch version-14 --depth 1 --origin upstream
Cloning into 'frappe'...
remote: Enumerating objects: 3210, done.
remote: Counting objects: 100% (3210/3210), done.
remote: Compressing objects: 100% (2893/2893), done.
remote: Total 3210 (delta 425), reused 1758 (delta 216), pack-reused 0
Receiving objects: 100% (3210/3210), 16.96 MiB | 14.92 MiB/s, done.
Resolving deltas: 100% (425/425), done.
Installing frappe
$ /home/erpnext/frappe-bench/env/bin/python -m pip install --quiet --upgrade -e /home/erpnext/frappe-bench/apps/frappe 
$ yarn install
yarn install v1.22.19
[1/5] Validating package.json...
[2/5] Resolving packages...
[3/5] Fetching packages...
[############################################################################-------------------------------------------------] 324/530^[4/5] Linking dependencies...
warning " > @frappe/esbuild-plugin-postcss2@0.1.3" has unmet peer dependency "less@^4.x".
warning " > @frappe/esbuild-plugin-postcss2@0.1.3" has unmet peer dependency "stylus@^0.x".
[5/5] Building fresh packages...
$ npm run snyk-protect

> snyk-protect
> snyk-protect

Applied Snyk patches.
npm notice 
npm notice New major version of npm available! 8.5.5 -> 9.6.7
npm notice Changelog: https://github.com/npm/cli/releases/tag/v9.6.7
npm notice Run npm install -g npm@9.6.7 to update!
npm notice 
Done in 53.22s.
Found existing apps updating states...
WARN: restart failed: Couldn't find supervisorctl in PATH
$ bench build
Assets for Release v14.37.0 don't exist
✔ Application Assets Linked                                                                                                             

yarn run v1.22.19
$ node esbuild --production --run-build-command
clean: postcss.plugin was deprecated. Migration guide:
https://evilmartians.com/chronicles/postcss-8-plugin-migration
clean: postcss.plugin was deprecated. Migration guide:
https://evilmartians.com/chronicles/postcss-8-plugin-migration
Browserslist: caniuse-lite is outdated. Please run:
  npx browserslist@latest --update-db
  Why you should do it regularly: https://github.com/browserslist/browserslist#browsers-data-updating
clean: postcss.plugin was deprecated. Migration guide:
https://evilmartians.com/chronicles/postcss-8-plugin-migration
clean: postcss.plugin was deprecated. Migration guide:
https://evilmartians.com/chronicles/postcss-8-plugin-migration
clean: postcss.plugin was deprecated. Migration guide:
https://evilmartians.com/chronicles/postcss-8-plugin-migration
clean: postcss.plugin was deprecated. Migration guide:
https://evilmartians.com/chronicles/postcss-8-plugin-migration
clean: postcss.plugin was deprecated. Migration guide:
https://evilmartians.com/chronicles/postcss-8-plugin-migration
File                                                        Size

frappe/dist/js/
├─ bootstrap-4-web.bundle.22U72DEL.js                       1.73 Kb
├─ controls.bundle.DFF2HAYM.js                              1228.77 Kb
├─ data_import_tools.bundle.ZHGGYJ52.js                     106.10 Kb
├─ desk.bundle.F6VOTWOZ.js                                  1422.47 Kb
├─ dialog.bundle.YMH3F5JU.js                                54.14 Kb
├─ form.bundle.BQYTYJFC.js                                  154.02 Kb
├─ frappe-web.bundle.OFX5DKXL.js                            952.95 Kb
├─ libs.bundle.YZMCKPNH.js                                  574.13 Kb
├─ list.bundle.OHONPWA4.js                                  189.47 Kb
├─ logtypes.bundle.7STJ7YLS.js                              0.73 Kb
├─ onboarding_tours.bundle.DSTT3JYE.js                      7.38 Kb
├─ recorder.bundle.5AOEUOFD.js                              179.54 Kb
├─ report.bundle.IKFONGWA.js                                171.58 Kb
├─ telemetry.bundle.PM4NETTP.js                             2.12 Kb
├─ user_profile_controller.bundle.YR6XHZRM.js               11.35 Kb
├─ video_player.bundle.UO3KNN5D.js                          120.59 Kb
├─ web_form.bundle.PZ4D2XJB.js                              1564.12 Kb
├─ print_format_builder.bundle.4NK3JYLN.js                  170.41 Kb
├─ build_events.bundle.L2HAVD4K.js                          11.62 Kb
└─ kanban_board.bundle.AHRTMM5S.js                          27.87 Kb

frappe/dist/css/
├─ desk.bundle.FDCSGWHG.css                                 549.26 Kb
├─ email.bundle.XXLSLIM6.css                                4.02 Kb
├─ login.bundle.ZQ33BOIF.css                                27.85 Kb
├─ print.bundle.P45PYX5D.css                                196.50 Kb
├─ print_format.bundle.N56JVME7.css                         179.01 Kb
├─ report.bundle.OBT4AB64.css                               5.36 Kb
├─ web_form.bundle.QMAAIEUZ.css                             14.73 Kb
└─ website.bundle.6PHX6AZV.css                              424.29 Kb

frappe/dist/css-rtl/
├─ desk.bundle.B2UOILHH.css                                 549.51 Kb
├─ email.bundle.VSTQ3FOG.css                                4.02 Kb
├─ login.bundle.UOU432ZW.css                                27.84 Kb
├─ print.bundle.SDJJGZKK.css                                196.65 Kb
├─ print_format.bundle.NWMJH2AM.css                         179.13 Kb
├─ report.bundle.KUUFQY5Q.css                               5.35 Kb
├─ web_form.bundle.CC54N5TN.css                             14.72 Kb
└─ website.bundle.KQX67XCU.css                              424.44 Kb

 DONE  Total Build Time: 35.594s

 WARN  Cannot connect to redis_cache to update assets_json
 WARN  Cannot connect to redis_cache to update assets_json
 WARN  Cannot connect to redis_cache to update assets_json
Done in 40.19s.
SUCCESS: Bench frappe-bench initialized
erpnext@vps:~$ 

Switch directory into the Frappe Bench directory,

cd frappe-bench

Change user directory permissions to set execution permission to the home directory,

chmod -R o+rx /home/[frappe-user]

Create a New Site,

bench new-site dev1.domainhere.info

It'll prompt you to set the password for Administrator user, can set strong password

Output:

erpnext@vps:~/frappe-bench$ bench new-site erp.domainhere.info
MySQL root password: 

Installing frappe...
Updating DocTypes for frappe        : [========================================] 100%
Updating country info               : [========================================] 100%
Set Administrator password: 
Re-enter Administrator password: 

Replace dev1.domainhere.info with actual domain name

Install ERPNext and other Apps

Download all the apps using below commands,

Download payments app using below command,

bench get-app payments

Download ERPNext app using below command,

bench get-app --branch version-14 erpnext

Download hrms using below command,

bench get-app hrms

Install all the apps on our site

bench --site dev1.domainhere.info install-app erpnext

bench --site dev1.domainhere.info install-app hrms

Start the bench using below command,

bench start

Note: This instances which are running on develop mode, this will not get started when you restart your server. You will need to run the bench start command every time the server restarts.

In the below steps, we will learn how to deploy the production mode.

Setting ERPNext for Production Usage

Enable Scheduler

bench --site dev1.domainhere.info enable-scheduler

Output:

erpnext@vps:~/frappe-bench$ bench --site erp.domainhere.info enable-scheduler
Enabled for erp.domainhere.info
erpnext@vps:~/frappe-bench$

Disable maintenance mode,

bench --site dev1.domainhere.info set-maintenance-mode off

Setup production config,

sudo bench setup production dev1.domainhere.info

Setup NGINX to apply the changes,

bench setup nginx

Install supervisor using below command,

sudo apt install supervisor

Restart Supervisor and Launch Production Mode,

sudo supervisorctl restart all
sudo bench setup production [frappe-user]

If you are prompted to save the new/existing config file, respond with a Y.

When this completes doing the settings, your instance is now on production mode and can be accessed using your IP, without needing to use the port.

This also will mean that your instance will start automatically even in the event you restart the server.

Setup Let’s Encrypt SSL/TLS Certificates with NGINX

Download the Let’s Encrypt Client,

sudo apt-get install certbot python3-certbot-nginx

To obtain SSL certificate need to update all the packages with required versions,

pip install urllib3==1.26.15 requests-toolbelt==0.10.1

Obtain the SSL/TLS Certificate

While installing Erpnext the frappe-bench.conf file already created by system, so need to obtain the SSL/TCL Certificate,

sudo certbot --nginx -d dev1.domainhere.info

Output:

Congratulations! You have successfully enabled https://dev1.domainhere.info  

-------------------------------------------------------------------------------------
IMPORTANT NOTES: 

Congratulations! Your certificate and chain have been saved at: 
/etc/letsencrypt/live/dev1.domainhere.info/fullchain.pem 
Your key file has been saved at: 
/etc/letsencrypt/live/dev1.domainhere.info//privkey.pem

Navigate Erpnext

images

images

images

images

images

Done.


CrownCloud - Get a SSD powered KVM VPS at $4.5/month!
Use the code WELCOME for 10% off!

1 GB RAM / 25 GB SSD / 1 CPU Core / 1 TB Bandwidth per month

Available Locations: LAX | MIA | ATL | FRA | AMS