Hosting erpNEXT version 14: Seamless Hosting

Collins Hillary
4 min readOct 7, 2023

--

Have you tried hosting the open-source version of erpNext? I know it’s a bit hectic especially if you are not using the containerization(docker) path.

Lucky for you! Today I will be showing you the relevant commands to be able to host the production version manually in your Ubuntu instance. This will give you complete control of your application and dependencies and of course the power of erpNext.

Let’s Begin!

Prerequisites

  1. Ubuntu instance

2. Hardware Requirements (minimum requirements)

  • 4GB RAM
  • 40GB Hard Disk

That’s it but be careful about the hardware requirements!

Okay, let’s now proceed with the actual installation.

ERPNext Installation

  1. Log in to your instance via SSH because we need access to the terminal ( the user should be a sudo at least)
  2. Now run the commands below exactly as they are.

“#” are comments that don’t copy.

Anything inside “[ ]” are placeholder, so change your values

# start by updating and upgrading your ubuntu instance
sudo apt-get update -y

sudo apt-get upgrade -y

# add a user so that we don't use the default super root to install our erpNext(security purposes)
sudo adduser [frappe-user] #[frappe-user] can be any name you choose

usermod -aG sudo [frappe-user]

# change the logged in user to the new user you created above
su [frappe-user]

cd /home/[frappe-user]

# let's install the relevant dependancies
# git
sudo apt-get install git

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

# python3 virtual environment
sudo apt-get install python3.10-venv

# for repository management
sudo apt-get install software-properties-common

# erpNext uses mariadb so we need this installed
sudo apt install mariadb-server mariadb-client

# redis
sudo apt-get install redis-server

# required by erpNext for purposes such as pdf printing and fonts
sudo apt-get install xvfb libfontconfig wkhtmltopdf

sudo apt-get install libmysqlclient-dev

# we need to setup a secure mariadb, once you run the command below, you will be prompted to answer the questions that follow
sudo mysql_secure_installation
Enter current password for root: (Enter your SSH root user password)
Switch to unix_socket authentication [Y/n]: Y
Change the root password? [Y/n]: Y
It will ask you to set new MySQL root password at this step. This can be different from the SSH root user password.
Remove anonymous users? [Y/n] Y
Disallow root login remotely? [Y/n]: N
This is set as N because we might want to access the database from a remote server for using business analytics software like Metabase / PowerBI / Tableau, etc.
Remove test database and access to it? [Y/n]: Y
Reload privilege tables now? [Y/n]: Y

# modify the .conf file to allow erpNext to have the right database formats and tables
# also to note, if you have other includes in the .cnf file, you need to comment them out
sudo nano /etc/mysql/my.cnf
[mysqld]
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci

[mysql]
default-character-set = utf8mb4

# restart the service for the .cnf changes to be picked
sudo service mysql restart

# curl
sudo apt install curl

# nvm for node js installation
curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash

# this reloads your terminal
source ~/.profile

nvm install 16.15.0

# npm
sudo apt-get install npm

# yarn
sudo npm install -g yarn

# here we begin installing the frappe framework which is used by erpNext
sudo pip3 install frappe-bench

# we need supervisor for automatic management of our application
sudo apt-get install supervisor

# using bench we initiate a new frappe project
bench init --frappe-branch version-14 frappe-bench

# navigate to the new folder created
cd frappe-bench

# this will give the bench user execution permission to the home directory.
chmod -R o+rx /home/[frappe-user]

# while inside the folder, create a new site
bench new-site [site-name] # the [site-name] could be anything, e.g erp.devligence.com

# ensure that bench uses our new site
bench use [site-name]

# allow bench to setup your nginx environment
bench setup nginx

# erpNext requires the payments app, so we will get it
bench get-app payments

# we then get the actual erpnext application
bench get-app --branch version-14 erpnext

# before proceeding you can get any other erpNext apps, like hrms of healthcare and such....e.g bench get-app hrms
# you will then need to install all the apps you have called above to the site created as below

# install the erpnext app to our site
bench --site [site-name] install-app erpnext

# install the hrms app to our site
bench --site [site-name] install-app hrms

# now here is the production commands
# enable the scheduler
bench --site [site-name] enable-scheduler

# set maintanance mode off
bench --site [site-name] set-maintenance-mode off

# allow bench to setup your production environment. Incase of any prompts answer with Y
sudo bench setup production [frappe-user]

# restart all apps using supervisort
sudo supervisorctl restart all

# run this one more to start the erpNext instance
sudo bench setup production [frappe-user]

When this completes, your instance is now in 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.

That’s all! quite simple right?

Author: Collins .H. Munene

Socials: LinkedIn

Profession: Founder | Software Engineer | DevOps | Security Analyst | AI & VR enthusiast | Mentor

Sponsored by: Devligence Limited and Larry Academy

--

--

Collins Hillary
Collins Hillary

Written by Collins Hillary

Software and Immersive Tech Developer and Security Analyst

No responses yet