How to install ERPNext on Ubuntu 20.04

If you are a non-techy or do not want the headache, I can offer to install it for you. You can just put a comment on this post or reach me out on Twitter at @ghulamostafa.

For ERPNext REST API calls please click here.

ERPNext is a free, open-source ERP system written in the Frappe framework. Simple yet powerful, it is designed for small and medium businesses that support retail, trading, services, manufacturing, distribution, non-profits and other sectors.
It is built with open source tools and offer features that can be used to run your business and collaborate with your customers and employees.
It also comes with a simple and user-friendly web interface with all functionalities of an ERP system.

DigitalOcean Droplet

We will go through a step by step tutorial on installing ERPNext on Ubuntu 20.04. For this article, we will use a virtual machine (droplet) from DigitalOcean. We will install a production version of ERPNext with 2GB RAM and 2 CPUs.

On creation of the Droplet, we will be a given a public IP address and we will access our virtual machine using Putty.

On logging in the machine run the following commands to upgrade all installed packages:

apt-get update -y
apt-get upgrade -y

Install required dependencies

First, you will need to install Python and other packages required to build and set up ERPNext. You can install them using the following command:

apt-get install libffi-dev python3-pip python3-dev  python3-testresources libssl-dev wkhtmltopdf gcc g++ make -y

Install Node.js

ERPNext uses Node.js for its frontend, therefore you will need to install it on your server. First, add the Node.js version 12 repository using the following command:

curl -sL https://deb.nodesource.com/setup_12.x | bash -

Once the repository is added, run the following command to install Node.js and Redis server in your system.

apt-get install nodejs redis-server -y

Once both packages are installed, you can verify the Node.js version using the following command:

node --version

Next, install the Yarn package by running the following command:

npm install -g yarn

Install and Configure MariaDB Server

First, install the MariaDB server by running the following command:

apt-get install mariadb-server mariadb-client -y

Once installed, secure the MariaDB and set the MariaDB root password with the following command:

mysql_secure_installation

Answer all the questions as shown below to set the MariaDB root password and secure the installation:

Enter current password for root (enter for none): Press your [Enter] key, there is no password set by default
Set root password? [Y/n] Y
New password:
Re-enter new password:
Remove anonymous users? [Y/n] Y
Disallow root login remotely? [Y/n] Y
Remove test database and access to it? [Y/n] Y
Reload privilege tables now? [Y/n] Y

Once the MariaDB is secured, log in to the MariaDB console with the following command:

mysql -u root -p

After login, change the MariaDB authentication plugin with the following command:

> USE mysql;
> UPDATE user SET plugin='mysql_native_password' WHERE User='root';

Next, flush the privileges and exit from the MariaDB shell with the following command:

> FLUSH PRIVILEGES;
> EXIT;

Next, you will need to change MariaDB Innodb file format to Barracuda. You can configure it by editing the file /etc/mysql/mariadb.conf.d/50-server.cnf:

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

Add/Modify the following lines:

[mysqld]
innodb-file-format=barracuda
innodb-file-per-table=1
innodb-large-prefix=1
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_unipre_ci

In the same file, below you will find:

collation-server = utf8mb4_general_ci

Replace it with

collation-server = utf8mb4_unicode_ci

Save and close the file, then restart the MariaDB service to implement the changes:

systemctl restart mariadb

Create a User for ERPNext

Before starting, you will need to create a user to run the ERPNext.

Create a new user named erpnext by running the following command:

useradd -m -s /bin/bash erpnext

Next, set the password with the following command:

passwd erpnext

Next, add the erpnext user to the sudo group so that it can run the superuser command:

usermod -aG sudo erpnext

Next, log in to the erpnext user and set up the environment variables with the following command:

su - erpnext
nano ~/.bashrc

Add the following line (anywhere):

PATH=$PATH:~/.local/bin/

Save and close the file, then activate the environment variable with the following command:

source ~/.bashrc

Install ERPNext

Next, you will need to install bench tool to install and manage ERPNext on your system.

This should be done using the erpnext user. Switch to erpnext if you are still on root:

su - erpnext

Create a new directory for ERPNext setup with the following command:

sudo mkdir /opt/bench

Next, change the ownership to the erpnext user:

sudo chown -R erpnext:erpnext /opt/bench

Next, change the directory to /opt/bench and clone the bench repository from Git:

cd /opt/bench
git clone https://github.com/frappe/bench bench-repo

Next, install the bench repo using the pip3 command:

pip3 install -e bench-repo

Once installed, initialize the bench directory with Frappe framework using the following command:

bench init erpnext

You should see the following output:

✔ Built <many .js files will appear one by one>
INFO:bench.utils:setting up backups
SUCCESS: Bench erpnext initialized

Next, change the directory to erpnext and download the erpnext app from GitHub with the following command:

bench get-app erpnext https://github.com/frappe/erpnext

After downloading the app, create a new frappe site with the following command:

bench new-site erpnext.example.com

You will be asked to provide your MariaDB root password, as shown below:

WARN: bench is installed in editable mode!
This is not the recommended mode of installation for production. Instead, install the package from PyPI with: `pip install frappe-bench`
MySQL root password:

Provide your password and hit Enter to create a new Frappe site:

Installing frappe...
Updating DocTypes for frappe        : [========================================] 100%
Updating country info               : [========================================] 100%

Next, you will be asked to set an administrator password, as shown below:

Set Administrator password:
Re-enter Administrator password:

Then install ERPNext on Frappe

bench --site erpnext.ghulamustafa.com install-app erpnext

Now we have everything installed. It is time to set the production environment.

Production Environment and Public Access

In this section, we will install Supervisor to manage the ERPNext process and Nginx as a reverse proxy to access the ERPNext without using port 8000.

sudo apt-get -y install supervisor nginx

Next, install the frappe-bench add-on with the following command:

sudo pip3 install frappe-bench

Then change the path to to ERPNext folder by running the following command:

cd /opt/bench/erpnext

Next, run the following command to configure ERPNext for a production environment:

sudo /home/erpnext/.local/bin/bench setup production erpnext

You should see the following output:

Site erpnext.example.com assigned port: 80
$ sudo /usr/bin/supervisorctl reread
erpnext-redis: available
erpnext-web: available
erpnext-workers: available
$ sudo /usr/bin/supervisorctl update
erpnext-redis: added process group
erpnext-web: added process group
erpnext-workers: added process group
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
$ sudo systemctl reload nginx

Now you should be able to access your ERPNext application using the DigitalOcean IP Address from a browser.

After the step by step configurations in browser for ERPNext, you should see the following:

Sometimes due to server load, the Setup of ERPNext may fail. For that purpose, you may increase the http_timeout value. Run the following commands inside erpnext folder:

Time Out Increase
-bench config http_timeout 6000
-bench setup supervisor
-bench setup nginx
-sudo supervisorctl reload
-sudo service nginx reload

Thank you for reading this article.

For mapping your DigitalOcean to your subdomain, please read the following article:

22 thoughts on “How to install ERPNext on Ubuntu 20.04

  1. Hi, Thanks for this post.
    What if I wish to install ERPNext on a local Ubuntu 20 server instead of a Droplet on Digital Ocean?
    Could you please post a tutorial on this? If you have already written about this, pl post a link to that article. Thx.

  2. Thank you very much. The installation worked – I can see the site when I got the server URL. Question – what is the user credentials to login for the first time?

    1. After bench new-site erpnext.example.com, it would ask maria-db password. Once it installs, it would ask for Administrator password. That’s what you would set.

  3. After the process, I get the following screen when I access the droplet IP
    Welcome to nginx!
    If you see this page, the nginx web server is successfully installed and working. Further configuration is required.
    For online documentation and support please refer to nginx.org.
    Commercial support is available at nginx.com.
    Thank you for using nginx.

  4. I’ve fixed the error.

    This line –> bench –site erpnext.ghulamustafa.com install-app erpnext

    The site name should be the same as the name of the site in the sites folder.

    I had to reset the droplet and started afresh.

  5. I am facing the following error on executing bench –site erpnext.example.com install-app erpnext

    An error occurred while installing erpnext:
    (2003, “Can’t connect to MySQL server on ‘127.0.0.1’ ([Errno 22] Invalid argument)”)

    Kindly guide me.

  6. Hi Ghulam,
    How would you go about this if you want to install it to a local server instead of a droplet. Would it be that much of a difference, I will try it now with your guide for locally and let you know how it proceeded

      1. Great, I came that far until cloning the bench but then I get the error of the bench-repo is not a valid editable requirement while I am in the user erpnext and that I got the files of the git without issue. I would like to mention also on a clean install git and curl are not installed

  7. The command pip3 install -e bench-repo leads to ERROR: bench-repo is not a valid editable requirement. It should either be a path to a local project or a VCS URL (beginning with svn+, git+, hg+, or bzr+).

      1. Hi Ghulam,
        Eventually it all worked out with the docker deployment. This solved the issues of incompatible Jinja versions and the node update that is 14+ now. Thank you for being here and assisting.

Leave a Reply to Philip Eapen Cancel reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s