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 root@IP_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 server:

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.

22 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:
    root@ip-172-26-9-113:/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. erpnext@ubuntuserver:/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!
    erpnext@ubuntuserver:/opt/bench$

    why it give that?

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

  7. Dear Admin,
    I have got this problem while I am trying to initialized the bench? can you suggest something to have solution for this problem.

    Installing frappe
    $ erpnext/env/bin/pip install -q -U -e erpnext/apps/frappe
    ERROR: Exception:
    Traceback (most recent call last):
    File “/srv/bench/erpnext/env/lib/python3.8/site-packages/pip/_vendor/urllib3/response.py”, line 437, in _error_catcher
    yield
    File “/srv/bench/erpnext/env/lib/python3.8/site-packages/pip/_vendor/urllib3/response.py”, line 519, in read
    data = self._fp.read(amt) if not fp_closed else b””
    File “/srv/bench/erpnext/env/lib/python3.8/site-packages/pip/_vendor/cachecontrol/filewrapper.py”, line 62, in read
    data = self.__fp.read(amt)
    File “/usr/lib/python3.8/http/client.py”, line 454, in read
    n = self.readinto(b)
    File “/usr/lib/python3.8/http/client.py”, line 498, in readinto
    n = self.fp.readinto(b)
    File “/usr/lib/python3.8/socket.py”, line 669, in readinto
    return self._sock.recv_into(b)
    File “/usr/lib/python3.8/ssl.py”, line 1241, in recv_into
    return self.read(nbytes, buffer)
    File “/usr/lib/python3.8/ssl.py”, line 1099, in read
    return self._sslobj.read(len, buffer)
    socket.timeout: The read operation timed out

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
    File “/srv/bench/erpnext/env/lib/python3.8/site-packages/pip/_internal/cli/base_command.py”, line 216, in _main
    status = self.run(options, args)
    File “/srv/bench/erpnext/env/lib/python3.8/site-packages/pip/_internal/cli/req_command.py”, line 182, in wrapper
    return func(self, options, args)
    File “/srv/bench/erpnext/env/lib/python3.8/site-packages/pip/_internal/commands/install.py”, line 324, in run
    requirement_set = resolver.resolve(
    File “/srv/bench/erpnext/env/lib/python3.8/site-packages/pip/_internal/resolution/legacy/resolver.py”, line 183, in resolve
    discovered_reqs.extend(self._resolve_one(requirement_set, req))
    File “/srv/bench/erpnext/env/lib/python3.8/site-packages/pip/_internal/resolution/legacy/resolver.py”, line 388, in _resolve_one
    abstract_dist = self._get_abstract_dist_for(req_to_install)
    File “/srv/bench/erpnext/env/lib/python3.8/site-packages/pip/_internal/resolution/legacy/resolver.py”, line 340, in _get_abstract_dist_for
    abstract_dist = self.preparer.prepare_linked_requirement(req)
    File “/srv/bench/erpnext/env/lib/python3.8/site-packages/pip/_internal/operations/prepare.py”, line 467, in prepare_linked_requirement
    local_file = unpack_url(
    File “/srv/bench/erpnext/env/lib/python3.8/site-packages/pip/_internal/operations/prepare.py”, line 255, in unpack_url
    file = get_http_url(
    File “/srv/bench/erpnext/env/lib/python3.8/site-packages/pip/_internal/operations/prepare.py”, line 129, in get_http_url
    from_path, content_type = _download_http_url(
    File “/srv/bench/erpnext/env/lib/python3.8/site-packages/pip/_internal/operations/prepare.py”, line 282, in _download_http_url
    for chunk in download.chunks:
    File “/srv/bench/erpnext/env/lib/python3.8/site-packages/pip/_internal/network/utils.py”, line 64, in response_chunks
    for chunk in response.raw.stream(
    File “/srv/bench/erpnext/env/lib/python3.8/site-packages/pip/_vendor/urllib3/response.py”, line 576, in stream
    data = self.read(amt=amt, decode_content=decode_content)
    File “/srv/bench/erpnext/env/lib/python3.8/site-packages/pip/_vendor/urllib3/response.py”, line 541, in read
    raise IncompleteRead(self._fp_bytes_read, self.length_remaining)
    File “/usr/lib/python3.8/contextlib.py”, line 131, in __exit__
    self.gen.throw(type, value, traceback)
    File “/srv/bench/erpnext/env/lib/python3.8/site-packages/pip/_vendor/urllib3/response.py”, line 442, in _error_catcher
    raise ReadTimeoutError(self._pool, None, “Read timed out.”)
    pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host=’files.pythonhosted.org’, port=443): Read timed out.

    • Please make sure that you installed all prerequisites before installing the frappe.

  8. When I create a new site using command after it request the Mysql root password it throws the following error.

    pymysql.err.OperationalError: (2003, “Can’t connect to MySQL server on ‘127.0.0.1’ ([Errno 111] Connection refused)”)

    I tried to figure out it but I couldn’t. I have passed all the steps well and reached that point. I am installing the ERPNext on virtual box Ubuntu server 20.04

  9. Dear Admin,

    When I create a new site using command after it request the Mysql root password it throws the following error.

    pymysql.err.OperationalError: (2003, “Can’t connect to MySQL server on ‘127.0.0.1’ ([Errno 111] Connection refused)”)

    I tried to figure out it but I couldn’t. I have passed all the steps well and reached that point. I am installing the ERPNext on virtual box Ubuntu server 20.04

  10. mysql -u root -p that also gives the following error

    mysql: unknown variable ‘pid-file=/run/mysqld/mysqld.pid’

    • Please make sure that your MySQL server is up and running.

  11. for me;
    there wore two probs
    1. when I run “bench new-site erpnext.example.com“
    asking me to enter db password after I enter the password i get this error
    “For key collation_server. Expected value utf8mb4_unicode_ci, found value latin1_swedish_ci“
    I solved this by changing `collation-server = utf8mb4_general_ci` to `collation-server = utf8mb4_unicode_ci` in `50-server.cnf` file

    2. in the production steps;
    when I run “sudo /home/erpnext/.local/bin/bench setup production erpnext“
    i get nginx default page in the browser
    instead of above i run “sudo bench setup production erpnext“

    its working now,
    just shared my experience if anyone face to same problem in Ubuntu 20.04

  12. At the end of Step 4, ‘Install and Configure MariaDB Server’, running the command, ‘systemctl restart mariadb’, mariadb would not start with the message “… Could not increase number of max_open_files to more than ….”
    I followed the steps outlined in https://stackoverflow.com/questions/60248748/could-not-increase-number-of-max-open-files-to-more-than-4096-request-4214 (purge mariadb and reinstall) and was able to start up mariadb.

    I repeated Step 4 from here starting with the mysql_secure_installation command.

  13. bench new-site erpnext.example.com
    errored for me as well – just as for commenter zia

    I needed to make the same changes as advised zia to 50-server.cnf
    I restarted mariadb “sudo systemctl restart mariadb”

    (replace example.com with your domain below)

    This allowed me to move further – however running “bench new-site erpnext.example.com” reported that the site already exists.

    Since the first attempt has resulted in an error – I thought it best to remove the site and retry. I needed to use “bench drop-site erpnext.exmple.com –force”
    I needed to use –force because drop-site reproted that it was unabel to create a back up

    I reran “bench new-site erpnext.example.com” and it seems to be working

Leave a Comment

To prove you are human please solve the following *