DEV Community

loading...
Cover image for How to install ERPNext 13 on Ubuntu 20.04

How to install ERPNext 13 on Ubuntu 20.04

multigoodsoftware profile image Chetan Mittal ・6 min read

I have written an instructions manual to install the latest ERPNext 13 on Ubuntu 20.04 server

- sign up on digitalocean
- generate a new ssh key (ignore if you already have one)
- add ssh key to your digitalocean account
- create a new 4GB droplet on digitalocean

$ssh root@-your-droplet-ip-address

- add 8GB swap space (i usually prefer swap 2 x ram but you can add 4GB swap too to save disk space)
Follow the guide here to add swap - https://www.digitalocean.com/community/tutorials/how-to-add-swap-space-on-ubuntu-20-04

- update server
> sudo apt update

- add locales
> sudo localectl set-keymap us && sudo localectl set-locale LANG=en_US.utf8
> sudo nano /etc/environment (and copy-paste following at the bottom of the file after $PATH)
####################
LC_ALL=en_US.UTF-8
LC_CTYPE=en_US.UTF-8
LANG=en_US.UTF-8
###################

- reboot for locales and server update
> sudo reboot

- install nginx
> sudo apt install nginx (and test by opening your-droptlet-ip-address in browser window)

## OPTIONAL ##

- install certbot (ubuntu 20.04 doesn’t support certbot-auto required by erpnext—frappe-bench thus we will use snap to install certbot classic to generate ssl certificates manually using lets encrypt)
> sudo service nginx stop
> sudo snap install --classic certbot

- generate lets encrypt ssl certificate for domain name(s) - certificate will be saved under -your-domain-name-folder-name at /etc/letsencrypt/live
> sudo certbot certonly --standalone (domain names will be asked here)
> sudo service nginx start

## OPTIONAL ENDS ##

- install mysql database server
> sudo apt install mariadb-server
> sudo apt install python3-mysqldb libmysqlclient-dev
> sudo mysql_secure_installation
> sudo systemctl stop mariadb
> sudo nano /etc/mysql/mariadb.conf.d/mariadb.cnf (and copy-paste following to save 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

# CONNECTIONS #

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

[mysql]
default-character-set = utf8mb4

[mysqldump]
max_allowed_packet=256M
####################

> sudo systemctl start mariadb
> sudo systemctl enable mariadb

- install ubuntu packages required for python3, etc.
> sudo DEBIAN_FRONTEND=noninteractive apt install -y curl build-essential python3-testresources 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 libdate-manip-perl logwatch

- add user 'frappe' with password 'password'
> adduser frappe
> usermod -aG sudo frappe
> rsync --archive --chown=frappe:frappe ~/.ssh /home/frappe/

- add mysql database and user 'frappe' with password 'password'
> mysql
> MariaDB [(none)]> CREATE DATABASE frappe;
> MariaDB [(none)]> SHOW DATABASES;
> MariaDB [(none)]> GRANT ALL PRIVILEGES ON *.* TO 'frappe'@'%' IDENTIFIED BY 'mariadb_password' WITH GRANT OPTION;
> MariaDB [(none)]> SELECT host, user, Super_priv FROM mysql.user;
> MariaDB [(none)]> FLUSH PRIVILEGES;
> MariaDB [(none)]> exit

## exit root user ##

——————————————————————————————

## ssh frappe user in new console or terminal window ##
$ssh frappe@-your-droplet-ip-address

- install some python3 based packages such as setuptools, etc
> sudo -H python3 -m pip install --upgrade setuptools cryptography psutil

- install wkhtmltopdf as erpnext12 requires 0.12.5 version (i am not sure about erpnext13 but installed just in case)
> cd /tmp
> wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox_0.12.5-1.bionic_amd64.deb
> sudo dpkg -i wkhtmltox_0.12.5-1.bionic_amd64.deb
> sudo cp /usr/local/bin/wkhtmlto* /usr/bin/
> cd ~
> sudo chmod a+x /usr/bin/wk*

- install Redis Cache Server
> sudo apt install git python-dev redis-server
> sudo apt-get install software-properties-common
> sudo apt-get install xvfb libfontconfig wkhtmltopdf
> sudo systemctl enable redis-server

- install nodejs, npm using nvm (node version manager) as erpnext13 requires nodejs12
> curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
> sudo reboot (required to run nvm command)
$ssh frappe
> nvm install 12
> npm install -g yarn

## verify nodejs, npm, yarn install ##
> frappe@mgs-erpnext:~$ yarn --version
1.22.10
frappe@mgs-erpnext:~$ npm -v
6.14.12
frappe@mgs-erpnext:~$ node -v
v12.22.1
frappe@mgs-erpnext:~$
## verify nodejs, npm, yarn install ENDS ##

Let’s summarize what we have accomplished so far. Up to this point, you have installed all the major components required by ERPNext 13, which include:

1. Nginx
2. Certbot
3. SSL Certificate Generate
4. Python3
5. MariaDB DB
6. Nodejs, NPM
7. The Yarn package manager
8. A Redis database cache
9. The wkhtmltopdf PDF documents generator

Whether you are installing the ERP system for development or for production, you are now ready for the next step, which is installing the Frappe full-stack framework and the actual ERPNext 13 web application.

——————————————————————————————

## ssh frappe user in new console or terminal window ##
$ssh frappe@-your-droplet-ip-address

- install bench (Installing Frappe Bench CLI)

> cd ~
> sudo chown frappe -R /home/frappe
> sudo pip3 install frappe-bench
> bench --version
> bench init frappe-bench
> cd frappe-bench
> echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
> ./env/bin/pip install numpy==1.18.5 && ./env/bin/pip install pandas==0.24.2 
(At this point the installation might halt for about 10 to 20 minutes while displaying above message :) so have a cup of coffee

- upgrade pip
> /home/frappe/frappe-bench/env/bin/python -m pip install --upgrade pip

- install bench apps
> bench get-app erpnext

- add new site to bench
> bench new-site -your-domain-name-or-droplet-ip-address- --admin-password -your-admin-password- --mariadb-root-username frappe --mariadb-root-password 'password'

- install bench app to bench site
> bench --site -your-domain-name-or-droplet-ip-address- install-app erpnext

- test bench on port 8000
> bench start
# open browser window and open -your-domain-name-or-droplet-ip-address-:8000 to test

——————————————————————————————

## setup production server using nginx etc ##

## ssh frappe user in new console or terminal window ##
$ssh frappe@-your-droplet-ip-address

> cd /home/frappe/frappe-bench
> sudo bench setup production frappe --yes

## verify if services work ##
> sudo supervisorctl stop all
> sudo supervisorctl start all
> systemctl list-unit-files | grep 'fail2ban\|nginx\|supervisor'
## verify if services work END ##

After confirming that everything is working as expected, you can test ERPNext 13 live on your server. Open your favorite browser and navigate to -your-domain-name-or-droplet-ip-address-, or whereever you are hosting your ERPNext 13 application.

After a few seconds, you should see the ERPNext 13 login screen. Use Administrator for the username (email) and the erpnext_admin_password you created previously for the password.

# the nginx conf file is saved in path below:-
> sudo nano /etc/nginx/conf.d/frappe-bench.conf

——————————————————————————————

## add https ##

## ssh frappe user in new console or terminal window ##
$ssh frappe@-your-droplet-ip-address

## OPTIONAL ##
- add cname to apex domain
> sudo -H bench setup add-domain -your-cname-domain-name-
> sudo -H bench setup nginx
> sudo service nginx reload
## OPTIONAL END ##

- turn on multi tenancy for https to work
> sudo -H bench config dns_multitenant on
> sudo -H bench setup nginx
> sudo service nginx reload

- add ssl certificate (letsencrypt) to bench site (install https on apex domain) - frappe-bench uses the same path /etc/letsencrypt/live to get ssl certificates
> sudo -H bench setup lets-encrypt -your-domain-name-or-droplet-ip-address- —custom-domain -your-cname-domain-name-
> sudo -H bench setup nginx
> sudo service nginx reload

——————————————————————————————

# Start using ERPNext

- open -your-domain-name-or-droplet-ip-address- in browser window

Enter fullscreen mode Exit fullscreen mode

Originally Posted on Multi Good Software Blog

Discussion (0)

Forem Open with the Forem app