How to install and setup ERPNext on Ubuntu

ERPNext Installation & Setup Guide

The state of open-source ERP systems

Open source software has always affected the IT and software industry since a long time. Starting with Linux, it’s now almost impossible to build a complex software without relying on open-source libraries and frameworks. Time and time again, open source ecosystem has proved itself by giving away generous amount of code for everyone to use and enhance.

Of late, software as complex as ERP systems are being developed with open-source philosophy. Meaning there source code is available to use and modify freely. Of couse, some are less open-source than others. The less open ones are called as Open Core software. Which means that their core framework is available as open source software, everything else built on that framework is either proprietary or made available for non-commercial use.

There are multiple open source ERP systems in development currently. Some of the most used are-

  • ERPNext
  • Odoo
  • Dolibarr
  • Compiere

Out of these, Odoo is rather limited in their open-source based product offering because they offer a commercial version as well. Rest all are truly open-source software.

Case in Point- ERPNext

ERPNext is a web-based ERP system and developed as open-source software by Frappe Technologies Pvt. Ltd., India. It’s been improving with each release for almost a decade. All of the contributions made to it are open-source and available for everyone to benefit.

ERPNext has been gathering a lot of attention lately because of its ease-of-use, and an amazing and inviting community. Many organizations throughout the world have contributed to the source code of ERPNext. One can integrate varoious external systems like Woocommerce, Tally etc into ERPNext is extend their current software stack easily.

How to Setup ERPNext on Ubuntu

ERPNext looks rather daunting when you first start using it. Moreover, the installation itself is a bit complex. But this is expected given that we’re talking about an ERP system which covers a lot of industries and their workflows.

However, Bench eases the overall installation procedure. Let’s begin.

Hardware Requirements for ERPNext Installation

  • A VPS/Linux System Ubuntu installed
  • Min 2 GB RAM & 2 CPU

ERPNext Installation steps

Let’s install the software required by Bench (assuming that you’re logged in a Linux system with root/sudo user).

#apt-get -y update \
    && apt-get -y install \
    build-essential \
    python-setuptools \
    wget \
    cron \
    sudo \
    locales \
    git \
    supervisor \
    nginx \
    gettext-base \
    libssl1.0-dev

The above command will install various dependencies like git, python tools, etc. This will also install supervisor and nginx for production setup.

The following command will fix the issue when Bench tries to create a user in the system (for “cmd”: “chsh frappe -s $(which bash)”, “stderr”: “Password: chsh: PAM: Authentication failure”).

#sed -i 's/auth       required   pam_shells.so/auth       sufficient   pam_shells.so/' /etc/pam.d/chsh

Set Locales

#sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen \
    && locale-gen
#LC_ALL=en_US.UTF-8 \
    LC_CTYPE=en_US.UTF-8 \
    LANG=en_US.UTF-8

Manually install MariaDB with frontend noninteractive to skip root password change.

#apt-get update \
    && apt-get install -y software-properties-common dirmngr \
    && apt-key adv --no-tty --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8 \
    && add-apt-repository 'deb [arch=amd64,i386,ppc64el] http://nyc2.mirrors.digitalocean.com/mariadb/repo/10.3/debian stretch main' \
    && export DEBIAN_FRONTEND=noninteractive \
    && apt-get update \
    && apt-get install -y \
    mariadb-server \
    mariadb-client \
    mariadb-common \
    libmariadbclient18 \
    python-mysqldb \
    python3-mysqldb

Add user (frappe) without sudo password

#systemUser=frappe
#adduser --disabled-password --gecos "" frappe \
    && usermod -aG sudo frappe \
    && echo "%sudo  ALL=(ALL)  NOPASSWD: ALL" > /etc/sudoers.d/sudoers

Set user and word directory

#su - frappe
$cd /home/frappe

Update /etc/mysql/conf.d/mariadb.cnf with the following contents-

# MariaDB-specific config file.
# Read by /etc/mysql/my.cnf


[mysql]
default-character-set = utf8mb4


[client]
# Default is Latin1, if you need UTF-8 set this (also in server section)
#default-character-set = utf8


[mysqld]
# Character sets
# Default is Latin1, if you need UTF-8 set all this (also in client section)
# character-set-server  = utf8
# collation-server      = utf8_general_ci

# Import all .cnf files from configuration directory
!includedir /etc/mysql/mariadb.conf.d/

bind-address = 0.0.0.0

character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci


[mysqld_safe]
skip_log_error
syslog


[mysqldump]
quick
quote-names
max_allowed_packet	= 16M

To ease further steps, let’s define some environment variables in bash-

easyinstallRepo='https://raw.githubusercontent.com/frappe/bench/master/playbooks/install.py' \
    benchPath=bench-repo \
    benchBranch=master \
    benchFolderName=bench \
    benchRepo='https://github.com/frappe/bench' \
    frappeRepo='https://github.com/frappe/frappe' \
    erpnextRepo='https://github.com/frappe/erpnext' \
    siteName=site1.local \
    adminPass=12345 \
    pythonVersion=python \
    appBranch=master

In the above command, you can set “pythonVersion” as required. Use “python3” to use Python 3 for setting up bench.

Change mysql root password-

$sudo service mysql start \
    && mysql --user="root" --execute="ALTER USER 'root'@'localhost' IDENTIFIED BY 'mysql_password';"

Replace “mysql_password” with the mysql password that you intend to use (tip- use a very strong passphrase)

Clone bench repo-

$git clone $benchRepo /tmp/.bench --depth 1 --branch $benchBranch

Get easy install script from bench repo, and remove mariadb from the bench playbook (cloned earlier)

$wget $easyinstallRepo \
    && sed -i '/mariadb/d' /tmp/.bench/playbooks/site.yml \
    && python install.py \
    --without-bench-setup \

The above command will install the remaining dependencies like Redis, Yarn, Nodejs, wkhtmltopdf etc.

You may get an error when the playbook starts Redis server. This is because the Redis server is trying to bind to an IPv6 address which might not be active on your host. To mitigate this, you need to edit the redis config file.

$sudo vim /etc/redis/redis.conf

Locate the line “bind 127.0.0.1 ::1” and remove “::1” from it. Once again, restart the redis server

$sudo service redis-server restart

Let’s install bench now.

$rm -rf bench \
    && git clone --branch $benchBranch --depth 1 --origin upstream $benchRepo $benchPath  \
    && sudo pip install -e $benchPath \

Init bench folder

$bench init $benchFolderName --frappe-path $frappeRepo --frappe-branch $appBranch --python $pythonVersion

Install ERPNext & delete unnecessary apps

$cd $benchFolderName \
    && bench get-app erpnext $erpnextRepo --branch $appBranch \
    && bench update --patch \
    && rm -rf \
    apps/frappe_io \
    apps/foundation \
    && sed -i '/foundation\|frappe_io/d' sites/apps.txt

Start MariaDB & init new site

$sudo service mysql start \
    && bench new-site $siteName \
    --mariadb-root-password mysql_password  \
    --admin-password $adminPass \
    && bench --site $siteName install-app erpnext

Change back config for work around for “cmd”: “chsh frappe -s $(which bash)”, “stderr”: “Password: chsh: PAM: Authentication failure”

$sudo sed -i 's/auth       sufficient   pam_shells.so/auth       required   pam_shells.so/' /etc/pam.d/chsh

Setup Production Config for Bench

$bench setup production

The above command will setup nginx and supervisor in production mode.

Restart bench and it’s services

$bench restart

Open the web browser with your server’s IP address as- IP:8000/desk. You should see this-

ERPNext Login Screen

Conclusion

ERPNext is a great alternative to Odoo, Tally and other propritory ERP software systems. One can fully rely on it to implement their workflows with ease.

In this guide, we explored the installation of ERPNext on an Ubuntu server with MariaDB database. Let us know if you need help with ERPNext installation and related services. We provide affordable ERPNext customization and implementation services.

Stay tuned for more ERPNext integration, implementation & migration guides.