ERP-Next Installation Guide

June 1, 2021  |  Bachi Allamsetty

The following guide is a step by step instruction to setup an ERP-Next instance of your own. The Guide assumes that you have basic understanding of linux commands and have installed a DB earlier and used the DB shell.

We would be performing all the operations on a linux OS, preferably Ubuntu v20.04. If not you may want to tweak in the commands a bit to adjust according to your OS if the commands differ.

Before getting started with the installtion, we recommend you to head over to the offical site of Frappe to understand how it operates and why is it necessary for ERP Next installation.


Install Mariadb


Following link guides us to setup mariadb on our machine perfectly

https://computingforgeeks.com/how-to-install-mariadb-on-ubuntu-focal-fossa/


Creating a MariaDB Super Admin User


Execute the follwing commands one after the other post entering to DB shell

CREATE DATABASE <REPLACE_WITH_DB_NAME_OF_YOUR_CHOISE>;
GRANT ALL PRIVILEGES ON *.* TO '<REPLACE_WITH_YOUR_DB_USER_CREATED_WHILE_INSTALLING_MARIADB>'@'%' IDENTIFIED BY '<REPLACE_WITH_YOUR_STRONG_PASSWORD>' WITH GRANT OPTION;
SELECT host, user, Super_priv FROM mysql.user;
FLUSH PRIVILEGES;

Configuring MariaDB for ERPNext



Stop the running DB server using the following command

sudo systemctl stop mariadb

View the following file in the edit mode using your preferred editor.

sudo vim /etc/mysql/conf.d/settings.cnf

Paste the below code as is and save the file

[mysqld]

# GENERAL #
user                           = mysql
default-storage-engine         = InnoDB
socket                         = /var/lib/mysql/mysql.sock
pid-file                       = /var/lib/mysql/mysql.pid

# MyISAM #
key-buffer-size                = 32M
myisam-recover                 = FORCE,BACKUP

# SAFETY #
max-allowed-packet             = 256M
max-connect-errors             = 1000000
innodb                         = FORCE

# DATA STORAGE #
datadir                        = /var/lib/mysql/

# BINARY LOGGING #
log-bin                        = /var/lib/mysql/mysql-bin
expire-logs-days               = 14
sync-binlog                    = 1

# REPLICATION #
server-id                      = 1

# CACHES AND LIMITS #
tmp-table-size                 = 32M
max-heap-table-size            = 32M
query-cache-type               = 0
query-cache-size               = 0
max-connections                = 500
thread-cache-size              = 50
open-files-limit               = 65535
table-definition-cache         = 4096
table-open-cache               = 10240

# INNODB #
innodb-flush-method            = O_DIRECT
innodb-log-files-in-group      = 2
innodb-log-file-size           = 512M
innodb-flush-log-at-trx-commit = 1
innodb-file-per-table          = 1
innodb-buffer-pool-size        = 5462M
innodb-file-format             = barracuda
innodb-large-prefix            = 1
collation-server               = utf8mb4_unicode_ci
character-set-server           = utf8mb4
character-set-client-handshake = FALSE
max_allowed_packet             = 256M

# LOGGING #
log-error                      = /var/lib/mysql/mysql-error.log
log-queries-not-using-indexes  = 0
slow-query-log                 = 1
slow-query-log-file            = /var/lib/mysql/mysql-slow.log

[mysql]
default-character-set = utf8mb4

[mysqldump]
max_allowed_packet=256M

!includedir /etc/mysql/mariadb.conf.d/

View the following file in the edit mode using your preferred editor. Here we shall have the config related to ERP-Next

sudo vim /etc/mysql/mariadb.conf.d/erpnext.cnf

Paste the below code as is and save the file

[mysqld]

pid-file        = /var/run/mysqld/mysqld.pid
socket          = /var/run/mysqld/mysqld.sock
bind-address    = 0.0.0.0
collation-server = utf8mb4_unicode_ci

Restart the DB server in-order for all our configurations to get into action

sudo systemctl start mariadb

Test the DB connection with the user the was created

mysql --user <REPLACE_WITH_YOUR_USER> --password <REPLACE_WITH_YOUR_PASSWORD> --host=localhost --protocol=tcp --port=3306 test

Enable the DB service for further usage

sudo systemctl enable mariadb

Install dependencies required for ERP-Next


sudo apt install libmysqlclient-dev python3-mysqldb
sudo DEBIAN_FRONTEND=noninteractive apt install -y curl build-essential mariadb-client python3-setuptools python3-dev libffi-dev python3-pip libcurl4 dnsmasq fontconfig git htop libcrypto++-dev libfreetype6-dev liblcms2-dev libwebp-dev libxext6 libxrender1 libxslt1-dev libxslt1.1 libffi-dev ntpdate postfix python3-dev python-tk screen vim xfonts-75dpi xfonts-base zlib1g-dev apt-transport-https libsasl2-dev libldap2-dev libcups2-dev pv libjpeg8-dev libtiff5-dev tcl8.6-dev tk8.6-dev libssl-dev python3-mysqldb libdate-manip-perl logwatch

update pip3 and then install the latest versions of three additional Python modules required by ERPNext:

sudo apt install python3-testresources
sudo -H python3 -m pip install --upgrade setuptools cryptography psutil

Install NodeJs and Yarn

curl -sL https://deb.nodesource.com/setup_14.x -o nodesource_setup.sh
sudo bash nodesource_setup.sh
sudo apt install nodejs
sudo npm install -g yarn

Install wkhtmltopdf

cd /tmp
wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox_0.12.5-1.focal_amd64.deb
sudo dpkg -i wkhtmltox_0.12.5-1.focal_amd64.deb
sudo cp /usr/local/bin/wkhtmlto* /usr/bin/
sudo chmod a+x /usr/bin/wk*

Install Redis

sudo apt install redis-server
sudo systemctl enable redis-server

Create ERP-Next system user

sudo useradd -m -s /bin/bash <USER_OF_YOUR_CHOICE>
sudo passwd <PASSWORD_OF_YOUR_CHOICE>
sudo usermod -aG sudo <EARLIER_CREATED_USER>

Install Frappe bench

su - <YOUR_USER>
sudo -H pip3 install frappe-bench
bench --version

Setup Frappe framework environment

echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

Install ERP-Next

sudo mkdir /opt/bench
sudo chown -R <SYSTEM_USER_CREATED_EARLIER>:<SYSTEM_USER_CREATED_EARLIER> /opt/bench
cd /opt/bench
bench init erpnext --frappe-branch version-12
cd /opt/bench/erpnext

Set DB host in common config unless you have not changed any of the installation paths specified in the guide

View the below file path in the edit mode

vi /opt/bench/erpnext/sites/common_site_config.json

Add the below line of code only if not present else update only the value

"db_host": "127.0.0.1"

Let us now get the ERP-Next app

RUN THE BELOW COMMANDS IN TMUX SESSION

On ubuntu 20, you have to install specific versions of numpy/pandas

pip3 install numpy==1.18.5
pip3 install pandas==0.24.2
cd /opt/bench/erpnext
bench get-app erpnext https://github.com/frappe/erpnext --branch version-12

Create ERP-Next site

bench new-site <YOUR_SITE_NAME> --admin-password '<YOUR_ADMIN_PASSWORD>' --mariadb-root-username <DB_USER> --mariadb-root-password '<DB_PASSWORD>'

Insall ERP-Next app on site

bench --site <YOUR_SITE_NAME> install-app erpnext

Setting up ERP-Next for production

sudo bench setup production <YOUR_USER_NAME> --yes

Getting the right configuration supervisor and nginx config files and symbolic linking them

bench setup supervisor && sudo ln -s `pwd`/config/supervisor.conf /etc/supervisor/conf.d/frappe-bench.conf
bench setup nginx && sudo ln -s `pwd`/config/nginx.conf /etc/nginx/conf.d/frappe-bench.conf