A complete Guide to Install Frappe Bench in Ubuntu 20.04 LTS – ARM64 and install Frappe/ERPNext Application

Tested on Ubuntu 20.04 ARM64 Cloud Sever

Initialize environment

STEP 1 Set up Docker Container

docker run -e TZ=America/New_York -d -p 8080:80 -p 8000:8000 -e MYSQL_ROOT_PASSWORD=password --name erpnext13 mariadb:10.8.3
docker exec -it erpnext13 bash

STEP 2 Update Server

It is always a good idea to upgrade the Ubuntu package if anything is available, run the below command to upgrade and update.

apt update && apt upgrade -y
apt install software-properties-common -y
apt install sudo nano git wget curl -y

STEP 3 Create a new user

Create a new user. Some of the commands we will be running later in this tutorial should not be carried out as root. Here, we call the new user  erpnext or whatever you like. Enter a password for them when prompted. You can leave the user information at default values if you wish.

adduser erpnext
  • Output
New password: Q38zc6JAat7tTnVPsg
Retype new password: Q38zc6JAat7tTnVPsg
passwd: password updated successfully
Changing the user information for frappe
Enter the new value, or press ENTER for the default
	Full Name []: 
	Room Number []: 
	Work Phone []: 
	Home Phone []: 
	Other []: 
Is the information correct? [Y/n] Y

STEP 4 Grant permission and switch to new user

usermod -aG sudo erpnext
su - erpnext
cd ~

Install Dependency

Python 3.7+ (version 13) / Python 3.10+ (develop branch / v14+)
Node.js 14
Redis 6                                       (caching and realtime updates)
MariaDB 10.3.x / Postgres 9.5.x               (to run database driven apps)
yarn 1.12+                                    (js dependency manager)
pip 20+                                       (py dependency manager)
wkhtmltopdf (version 0.12.5 with patched qt)  (for pdf generation)
cron                                          (bench's scheduled jobs: automated certificate renewal, scheduled backups)
NGINX                                         (proxying multitenant sites in production)

Step-by-step dependency installation

  1. Python 3.8

Python-dev is the package that contains the header files for the Python C API, which is used by lxml because it includes Python C extensions for high performance.

sudo apt install python2 python3-venv python3-dev virtualenv -y
  • Node.js 14
  • curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
    source ~/.profile
    nvm install 14
  • Redis 6
    Resid can be used to process and analyze data in memory, this is prerequisite for ERPNext.
  • sudo apt install redis-server -y
    sudo systemctl enable redis-server
  • yarn 1.12+
  • sudo apt install npm -y
    sudo npm install -g yarn
  • pip 20+
  • Setuptools is a collection of enhancements to the Python distutils that allow developers to more easily build and distribute Python packages, especially ones that have dependencies on other packages. Packages built and distributed using setuptools look to the user like ordinary Python packages based on the distutils.

    Pip is a package manager for Python. It’s a tool that allows you to install and manage additional libraries and dependencies that are not distributed as part of the standard library.

    sudo apt install python3-setuptools python3-pip -y
  • wkhtmltopdf (version 0.12.5 with patched qt)
    Wkhtmltopdf is an open source simple and much effective command-line shell utility that enables user to convert any given HTML (Web Page) to PDF document or an image (jpg, png, etc).
  • sudo apt install xvfb libfontconfig wkhtmltopdf -y
  • cron
  • sudo apt install cron -y
  • NGINX
  • sudo apt install nginx -y
  • MariaDB 10.3.x
  • sudo apt install libmysqlclient-dev -y

    Quick dependency installation

    sudo apt install python2 python3-venv python3-dev virtualenv -y
    curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
    source ~/.profile
    nvm install 14
    sudo apt install redis-server -y
    sudo systemctl enable redis-server
    sudo apt install npm -y
    sudo npm install -g yarn
    sudo apt install python3-setuptools python3-pip -y
    sudo apt install xvfb libfontconfig wkhtmltopdf -y
    sudo apt install cron -y
    sudo apt install nginx -y
    sudo apt install libmysqlclient-dev -y

    Setup database

    The setup tool asks you to enter the current MySQL password. The default password is password

    sudo mysql_secure_installation
  • Output
  • Enter current password for root (enter for none): password
    OK, successfully used password, moving on...
    
    Setting the root password or using the unix_socket ensures that nobody
    can log into the MariaDB root user without the proper authorisation.
    
    You already have your root account protected, so you can safely answer 'n'.
    
    Switch to unix_socket authentication [Y/n] y
     ... skipping.
    
    You already have your root account protected, so you can safely answer 'n'.
    
    Change the root password? [Y/n] y
    New password: Q38zc6JAat7tTnVPsg
    Re-enter new password: Q38zc6JAat7tTnVPsg
    Password updated successfully!
    Reloading privilege tables..
     ... Success!
    
    
    By default, a MariaDB installation has an anonymous user, allowing anyone
    to log into MariaDB without having to have a user account created for
    them.  This is intended only for testing, and to make the installation
    go a bit smoother.  You should remove them before moving into a
    production environment.
    
    Remove anonymous users? [Y/n] y
     ... Success!
    
    Normally, root should only be allowed to connect from 'localhost'.  This
    ensures that someone cannot guess at the root password from the network.
    
    Disallow root login remotely? [Y/n] y
     ... Success!
    
    By default, MariaDB comes with a database named 'test' that anyone can
    access.  This is also intended only for testing, and should be removed
    before moving into a production environment.
    
    Remove test database and access to it? [Y/n] y
     - Dropping test database...
     ... Success!
     - Removing privileges on test database...
     ... Success!
    
    Reloading the privilege tables will ensure that all changes made so far
    will take effect immediately.
    
    Reload privilege tables now? [Y/n] y
     ... Success!
    
    Cleaning up...
    
    All done!  If you've completed all of the above steps, your MariaDB
    installation should now be secure.
    
    Thanks for using MariaDB!
    sudo mysql

    Create the new user account and grant superuser privileges to it.

    CREATE DATABASE erpnext;
    GRANT ALL PRIVILEGES ON *.* TO 'erpnext'@'%' IDENTIFIED BY 'Q38zc6JAat7tTnVPsg' WITH GRANT OPTION;
    FLUSH PRIVILEGES;
    EXIT;

    Open the file /etc/mysql/conf.d/50-server.cnf in a text editor.

    sudo nano /etc/mysql/conf.d/50-server.cnf

    Add the code below. Then save the file and exit the text editor.

    [mysqld]
    character-set-client-handshake = FALSE
    character-set-server = utf8mb4
    collation-server = utf8mb4_unicode_ci
    innodb_read_only_compressed = FALSE
    
    [mysql]
    default-character-set = utf8mb4

    Repeat step 10 for the file /etc/mysql/my.cnf.

    sudo nano /etc/mysql/my.cnf

    Restart the container

    sudo service mariadb restart

    Access the container

    docker start erpnext13
    docker exec -it erpnext13 bash
    su - erpnext

    Installing the Frappe Bench CLI

    cd /home/erpnext
    sudo -H pip3 install frappe-bench
    echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
    bench init /home/erpnext/frappe-bench --frappe-path https://github.com/frappe/frappe --frappe-branch version-13 --python python3

    Setting up ERPNext

    cd /home/erpnext/frappe-bench
    bench get-app ERPNext https://github.com/frappe/erpnext --branch version-13
    bench setup requirements
    bench new-site erp.example.com --admin-password 'password' --mariadb-root-username erpnext --mariadb-root-password 'Q38zc6JAat7tTnVPsg'

    Replace erp.example.com to your own domain or localhost

    bench --site erp.example.com install-app erpnext

    (Optional) Test if the site is working

    bench start

    Setup production mode

    sudo apt install supervisor -y
    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

    The first time will result an error, make sure you run it twice

    sudo bench setup production erpnext
    sudo bench setup production erpnext

    Fix no CSS loading

    chmod o+x /home/erpnext

    Start services for production

    sudo service nginx start
    sudo service supervisor start

    Reverse Proxy

    You can use install aapanel or nginx reverse proxy manager outside the container.

    https://www.aapanel.com/new/download.html

    https://nginxproxymanager.com/setup/#running-the-app

    Make sure you include this to fix the Websocket error

    location /socket.io/ {
        proxy_pass http://127.0.0.1:8080;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Real-IP $remote_addr;
        }

    ⚠️ Cautious

    1. Reinstall ERPNext command
    cd /home/erpnext/frappe-bench
    bench --site erp.example.com reinstall --admin-password 'password' --mariadb-root-username erpnext --mariadb-root-password 'Q38zc6JAat7tTnVPsg'
  • Remove default chart of account (For Quickbooks users)
  • delete from tabAccount where account_name not in ('Application of Funds (Assets)','Source of Funds (Liabilities)','Equity','Income','Expenses');


    🐛 Fix bugs

  • Unable to use bench restart
  • sudo nano /etc/supervisor/supervisord.conf
    [unix_http_server]
    file=/var/tmp/supervisord.sock
    chmod=0700
    chown=erpnext:erpnext
    sudo service supervisor stop
    sudo service supervisor start
  • Unable to use bench update
  • cd home/erpnext/apps/erpnext
    git stash


    REFERENCE

    https://syncbricks.com/erpnext-manual-install-ubuntu-20-04/

    https://discuss.erpnext.com/t/how-to-install-erpnext-through-docker-on-wsl/90892/4

    https://www.scaleway.com/en/docs/tutorials/erpnext-13/

    https://frappeframework.com/docs/v14/user/en/installation

    https://github.com/HUMENTH/Guide-to-Install-Frappe-ERPNext-in-Ubuntu-22.04-LTS

    https://discuss.erpnext.com/t/deleting-entire-chart-of-accounts-and-rebuilding/18891/3