How to Install ERPNext on Ubuntu 20.04

In this tutorial, we will show you how to install ERPNext on Ubuntu 20.04 using one of our optimized ERPNext hosting servers.

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.

ERPNext is one of the best ERP application used by thousands of businesses worldwide to manage their ERP processes. It offers a rich set of features including HR, Sales, Purchases, CRM, Manufacturing, Inventory and Accounting management. Let’s get started with the installation process.

Prerequisites

  • An Ubuntu 20.04 VPS with root access enabled (We include root access for free across all of our VPS plans) or a user with sudo privileges.
  • A valid domain name pointed to your server.
  • A minimum of 2GB of RAM and 2 CPU cores.

1. Log in via SSH and Update your System

First, you will need to log in to your Ubuntu 20.04 VPS via SSH as the root user:

ssh [email protected]_ADDRESS -p PORT_NUMBER

Make sure to replace “IP_ADDRESS” and “PORT_NUMBER” with their respective values. The default SSH port is 22, but it might be set to a different value on your server.

Next, run the following commands to upgrade all installed packages on your VPS:

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

Once your system is up-to-date, you can proceed to the next step.

2. 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

Once all of the packages are installed, you can proceed to the next step.

3. 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

You should get the following output:

v12.16.3

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

npm install -g yarn

Once the package is installed, you can proceed to the next step.

4. 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:

MariaDB [(none)]>USE mysql;
MariaDB [(none)]>UPDATE user SET plugin='mysql_native_password' WHERE User='root';

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

MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> 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
[mysql]
default-character-set = utf8mb4

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

systemctl restart mariadb

5. 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:

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

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

source ~/.bashrc

6. Install ERPNext

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

First, log in with ERPNext user and create a new directory for ERPNext setup with the following command:

su - erpnext
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 js/frappe-web.min.js
✔ Built css/web_form.css
✔ Built css/desk.min.css
✔ Built js/control.min.js
✔ Built css/frappe-web-b4.css
✔ Built js/form.min.js
✔ Built js/data_import_tools.min.js
✔ Built js/report.min.js
INFO:bench.utils:setting up backups
SUCCESS: Bench erpnext initialized

Next, change the directory to erpnext and create a new frappe site with the following command:

bench new-site erpnext.example.com

Make sure to replace example.com with your registered domain name. ou 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:

Provide your desired password and hit Enter to finish the process.

*** Scheduler is disabled ***
Current Site set to erpnext.example.com

Next, start the bench service with the following command:

bench start

You should see the following output:

13:51:25 web.1            |  * Running on http://0.0.0.0:8000/ (Press CTRL+C to quit)
13:51:25 web.1            |  * Restarting with inotify reloader
13:51:25 watch.1          | yarn run v1.22.4
13:51:25 watch.1          | $ node rollup/watch.js
13:51:26 web.1            |  * Debugger is active!
13:51:27 web.1            |  * Debugger PIN: 154-374-187
13:51:27 watch.1          |
13:51:27 watch.1          | Rollup Watcher Started

At this point, ERPNext is installed and listening on port 8000. However, this is not the recommended way to set up the production environment.

Press CRTL+C to stop the bench process and proceed to the next step.

7. Set up ERPNext for a Production Environment

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.

First, change the user to ERPNext and install Supervisor and Nginx with the following command:

su - erpnext
sudo apt-get -y install supervisor nginx

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

sudo pip3 install frappe-bench

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

8. Access ERPNext Web Interface

At this point, ERPNext is installed and configured to run on port 80. Now, open your web browser and type the URL http://erpnext.example.com. You will be redirected to the following page:

Provide username as Administrator and the password that you provided during installation and click on the Sign in button. You should see the language selection page:

Select your desired language and click on the Next button. You should see the following page:

Provide your country name, time zone, currency and then click on the Next button. You should see the following page:

Add your first user, email, password and click on the Complete Setup button. You should see the ERPNext dashboard in the following page:

Congratulations! you have successfully installed ERPNext on your Ubuntu 20.04 VPS. Now you can use this platform to expand and help your business.


Of course, you don’t have to install ERPNext on Ubuntu 20.04 if you have a Managed Ubuntu VPS with us. You can simply ask our support team to install ERPNext on Ubuntu 20.04 for you. They are available 24/7 and will be able to help you with the installation.

PS. If you enjoyed reading this blog post on How to Install ERPNext on Ubuntu 20.04, feel free to share it on social networks using the shortcuts below, or simply leave a comment in the comments section. Thanks.

13 thoughts on “How to Install ERPNext on Ubuntu 20.04”

  1. I did everything up to end of step 4 successfully, but when I tried to restart mariadb it failed:
    [email protected]:/home/ubuntu# journalctl -xe
    Sep 08 16:17:20 ip-172-26-9-113 mysqld[45951]: 2020-09-08 16:17:20 0 [ERROR] Aborting
    Sep 08 16:17:20 ip-172-26-9-113 systemd[1]: mariadb.service: Main process exited, code=exited, status=1/FAILURE
    — Subject: Unit process exited
    — Defined-By: systemd
    — Support: http://www.ubuntu.com/support

    — An ExecStart= process belonging to unit mariadb.service has exited.

    — The process’ exit code is ‘exited’ and its exit status is 1.
    Sep 08 16:17:20 ip-172-26-9-113 systemd[1]: mariadb.service: Failed with result ‘exit-code’.
    — Subject: Unit failed
    — Defined-By: systemd
    — Support: http://www.ubuntu.com/support

    — The unit mariadb.service has entered the ‘failed’ state with result ‘exit-code’.
    Sep 08 16:17:20 ip-172-26-9-113 systemd[1]: Failed to start MariaDB 10.3.22 database server.
    — Subject: A start job for unit mariadb.service has failed
    — Defined-By: systemd
    — Support: http://www.ubuntu.com/support

    — A start job for unit mariadb.service has finished with a failure.

  2. in reference to my last comment, I think this is the issue that I didn’t notice before.
    when I issue the UPDATE user… command I get this response:
    ERROR 1356 (HY000): View ‘mysql.user’ references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them

    Any ideas?

    • Have you tried to purge mariadb-server and mariadb-client, in prior of installing them?

      The issue seems to be with the permissions within your MariaDB instance.

  3. Hi,
    I followed your procedure to the letter, created user ‘erpnext’ Everthing went ok up to “bench init erpnext” which finished very well. then it all went downhill from there. maybe because my domain was set to erp.mydomain.com. I tried all night to fix, with my limited knowledge as a newbee, all to no avail. Also, I think some github comits have changed. could you please help?

    Martin

    • You need to change the “example.com” with your domain name and your domain should be pointed to your server IP address.

  4. I followed your guide and managed to run Frappe. But I do not see ERPNext anywhere?

    • If you followed the instructions carefully, EPRNext should be running on port 8000 on your server and you should be able to access it at your_domain:8000 in your browser (or only with your_domain if you also completed the reverse proxy setup with Supervisor in section 7 of the tutorial).

  5. I followed all the steps up to step 4 , it going fine
    When I run the command “mysql -u root -p”
    I got the following
    MariaDB [(none)]>
    then I run MariaDB [(none)]>USE mysql;
    then it changes to
    MariaDB [(mysql)]>, then i run the next command as
    MariaDB [(mysql)]>UPDATE user SET plugin=’mysql_native_password’ WHERE User=’root’;

    the I change the file “nano /etc/mysql/mariadb.conf.d/50-server.cnf ” as stated above.
    But after that when i run the following command I got error

    systemctl restart mariadb
    Job for mariadb.service failed because the control process exited with error code.
    See “systemctl status mariadb.service” and “journalctl -xe” for details.

    now even whe i run mysql -u root -p it doesn’t connect
    I need your help

    • please check if you have run all of the commands and haven’t made any typo

      • I followed as stated above
        the only difference is when I run MariaDB [(none)]>USE mysql;

        it give me MariaDB [(mysql)] the I run the “UPDATE user SET plugin=’mysql_native_password’ WHERE User=’root’; ” as

        MariaDB [(mysql)] > UPDATE user SET plugin=’mysql_native_password’ WHERE User=’root’;
        of course on the step above it shows as
        MariaDB[(none)]> UPDATE user SET plugin=’mysql_native_password’ WHERE User=’root’;
        /
        is that create a problem

        • You need to “be” inside of a database in order to execute DML statements in MySQL.

  6. [email protected]:/opt/bench$ bench init erpnext
    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`

    INFO: Path erpnext already exists!
    [email protected]:/opt/bench$

    why it give that?

    • There is an existing erpnext directory. You should remove that directory and re-do whole step.

Leave a Comment

To prove you are human please solve the following *