Hello,
In this week’s feature highlight, we look at How to Install Erpnext on Ubuntu 23.10
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 23.10 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 23.10 packages installed on the server 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 GIT
required packages using below command,
sudo apt-get install git
Install Python3.11
as ERPNext version 14 requires Python 3.10+ version,
sudo apt-get install python3 python3-dev python3-setuptools python3-pip python3-distutils
Install virtual environment to manage software at one place,
sudo apt-get install python3.11-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:
root@vps:/etc# nvm install 16.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:
test-user@vps:~$ bench init --frappe-branch version-14 frappe-bench
Setting Up Environment
$ python3 -m venv env
$ /home/test-user/frappe-bench/env/bin/python -m pip install --quiet --upgrade pip
$ /home/test-user/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: 3232, done.
remote: Counting objects: 100% (3232/3232), done.
remote: Compressing objects: 100% (2845/2845), done.
remote: Total 3232 (delta 376), reused 2141 (delta 276), pack-reused 0
Receiving objects: 100% (3232/3232), 16.32 MiB | 13.21 MiB/s, done.
Resolving deltas: 100% (376/376), done.
Installing frappe
$ /home/test-user/frappe-bench/env/bin/python -m pip install --quiet --upgrade -e /home/test-user/frappe-bench/apps/frappe
yarn install v1.22.19
[1/5] Validating package.json...
[2/5] Resolving packages...
[3/5] Fetching packages...
[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.
Done in 31.00s.
Found existing apps updating states...
WARN: restart failed: Couldn't find supervisorctl in PATH
$ bench build
Assets for Release v14.52.1 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.R2OTMVA3.js 1229.24 Kb
├─ data_import_tools.bundle.RUC5YCOC.js 106.86 Kb
├─ desk.bundle.2QM3JR5W.js 1430.18 Kb
├─ dialog.bundle.Y5TJIJW4.js 54.74 Kb
├─ form.bundle.T5ZOXKQ2.js 159.84 Kb
├─ frappe-web.bundle.NN3E7BYR.js 1174.75 Kb
├─ libs.bundle.5QWQF2M7.js 790.84 Kb
├─ list.bundle.HEX3PU62.js 190.70 Kb
├─ logtypes.bundle.7STJ7YLS.js 0.73 Kb
├─ onboarding_tours.bundle.DZEAOU4B.js 7.60 Kb
├─ recorder.bundle.TNXNMAOV.js 180.52 Kb
├─ report.bundle.KS2K2M5W.js 174.21 Kb
├─ telemetry.bundle.ESRPVZ24.js 2.22 Kb
├─ user_profile_controller.bundle.WCRWDNHY.js 11.98 Kb
├─ video_player.bundle.UO3KNN5D.js 120.59 Kb
├─ web_form.bundle.OKVM5ZTC.js 1565.49 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.CTY6MIMR.css 564.07 Kb
├─ email.bundle.RLW6XH5W.css 4.02 Kb
├─ login.bundle.4G5PRB46.css 27.68 Kb
├─ print.bundle.VZD5LWCU.css 196.34 Kb
├─ print_format.bundle.7UO6REWK.css 178.84 Kb
├─ report.bundle.YPCQHCLR.css 5.36 Kb
├─ web_form.bundle.JQXJ3GUB.css 14.73 Kb
└─ website.bundle.52ZHOHXZ.css 423.81 Kb
frappe/dist/css-rtl/
├─ desk.bundle.M4FIWVJV.css 564.34 Kb
├─ email.bundle.B43656HQ.css 4.02 Kb
├─ login.bundle.TJUYHYTB.css 27.67 Kb
├─ print.bundle.NJ55KAUB.css 196.49 Kb
├─ print_format.bundle.J4RXHREJ.css 178.96 Kb
├─ report.bundle.P7FMOYFQ.css 5.35 Kb
├─ web_form.bundle.HZREWTIN.css 14.72 Kb
└─ website.bundle.K4RPTYLP.css 423.96 Kb
DONE Total Build Time: 22.603s
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 26.89s.
SUCCESS: Bench frappe-bench initialized
test-user@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 erpnext.domainhere.info
Output:
test-user@vps:~/frappe-bench$ bench new-site erpnext.domainhere.info
MySQL root password:
Warning: MariaDB version ['10.11', '4'] is more than 10.8 which is not yet tested with Frappe Framework.
Restoring Database file...
12.1KiB 0:00:00 [9.89MiB/s] [========================================================================>] 100%
Installing frappe...
Updating DocTypes for frappe : [========================================] 100%
Updating country info : [========================================] 100%
Set Administrator password:
Re-enter Administrator password:
Updating Dashboard for frappe
erpnext.domainhere.info: SystemSettings.enable_scheduler is UNSET
*** Scheduler is disabled ***
test-user@vps:~/frappe-bench$
Replace erpnext.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 erpnext.domainhere.info install-app erpnext
bench --site erpnext.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 erpnext.domainhere.info enable-scheduler
Output:
test-user@vps:~/frappe-bench$ bench --site erpnext.domainhere.info enable-scheduler
Enabled for erpnext.domainhere.info
test-user@vps:~/frappe-bench$
Disable maintenance mode,
bench --site erpnext.domainhere.info set-maintenance-mode off
Setup production config,
sudo bench setup production erpnext.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 test-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
While installing Erpnext the frappe-bench.conf
file already created by system, so need to obtain the SSL/TCL Certificate,
sudo certbot --nginx -d erpnext.domainhere.info
Output:
test-user@vps:~/frappe-bench/sites$ sudo certbot --nginx -d erpnext.domainhere.info
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Requesting a certificate for erpnext.domainhere.info
Successfully received certificate.
Certificate is saved at: /etc/letsencrypt/live/erpnext.domainhere.info/fullchain.pem
Key is saved at: /etc/letsencrypt/live/erpnext.domainhere.info/privkey.pem
This certificate expires on 2024-01-19.
These files will be updated when the certificate renews.
Certbot has set up a scheduled task to automatically renew this certificate in the background.
Deploying certificate
Successfully deployed certificate for erpnext.domainhere.info to /etc/nginx/conf.d/frappe-bench.conf
Congratulations! You have successfully enabled HTTPS on https://erpnext.domainhere.info
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
test-user@vps:~/frappe-bench/sites$