How to Install ERPNext on Rocky Linux 9

ERPNext is an open-source Enterprise ERP (Enterprise Resource Planning) system that can be implemented in your business. ERPNext can be implemented in multiple types of industries, such as manufacturing, distribution, retail, trading, services, education, non-profits, and healthcare. Also, it provides modules like accounting, CRM, sales, purchasing, website, e-commerce, point of sale, manufacturing, warehouse, project management, inventory, and services.

ERPNext is an Enterprise ERP platform licensed under GNU General Public Licence v3. It's mainly written in Python and JavaScript, developed by Frappe Technologies Pvt. ERPNext is an application written under the frappe framework, an open-source web framework in Python and Javascript.

ERPNext is created as an alternative to services like NetSuite from oracle, QAD, Tython, OpenBrave, and Odoo. For functionality, ERPNext is similar to Odoo (formerly OpenERP).

In this tutorial, you will install the ERPNext on a Rocky Linux 9 server and then secure your installation with SSL/TLS certificates via Certbot and Letsencrypt. You'll also learn how to install dependencies for ERPNext such as Python 3.10 from source, Redis that will be used as session manager, Nginx as the web server and reverse proxy, Supervisor as the process manager, Fail2ban for protecting against brute force, MariaDB as the database server, Node.js and Yarn for building and compiling static files.

The ERPNext is an application built on top of the frappe framework, so you'll also install frappe framework in the process via frappe-bench.

Prerequistes

You will need some following requirements to complete this tutorial:

  • One Debian 11 server - This example uses a Debian server with the hostname 'erpnext-rocky'.
  • A non-root user with sudo/root administrator privileges. You will run all commands in this guide as a non-root user.
  • A domain name pointed to the server IP address.
  • An SELinux running with permissive mode.

Now let's get started and install ERPNext.

Setting up User

The first task in this tutorial is to create a new dedicated user that will be used to run the ERPNext application. You'll also use this new user to run all commands for package installation and configuration.

Run the below command to create a new user 'frappe'. Then, set up the password for the 'frappe' user, input the new strong password, and repeat the password.

sudo useradd -m -s /bin/bash frappe
sudo passwd frappe

Now run the below command to add the 'frappe' user to the 'wheel' group. This will allow the 'frappe' user to execute the sudo command become the root user or run the command as root privileges.

sudo usermod -aG wheel frappe

Lastly, log in as the 'frappe' user to verify and ensure that your user is created. Then, run the sudo su command to get the root privileges.

sudo - frappe
sudo su

Input your password for the 'frappe' user. If successful, your prompt will become such as 'root@hostname:/home/frappe...'.

setup user

Now type exit or press Ctrl+d to exit from the root shell.

Installing Python 3.10

ERPNext is a web application created using the frappe web framework based on Python. At the time of this writing, the latest version of the frappe framework and ERPNext required at least Python 3.10.

In this step, you will install Python 3.10 manually from the source on the Rocky Linux 9 server.

To begin, run the below dnf command to install some basic dependencies for compiling Python 3.10.

sudo dnf install gcc openssl-devel bzip2-devel libffi-devel zlib-devel wget make

Input y when prompted and press ENTER to proceed.

install dependencies

Next, download the Python 3.10 source code via the wget command below.

wget https://www.python.org/ftp/python/3.10.9/Python-3.10.9.tgz

After Python 3.10 is downloaded, extract the Python source code and move your working directory into it.

tar xzf Python-3.10.9.tgz
cd Python-*/

Next, run the below command to start compiling Python 3.10. Then install it to your system. This will install Python 3.10 binary files to the '/usr/local/bin' directory.

./configure --enable-optimizations
nproc
sudo make -j2
sudo make altinstall

compile python

Run the below command to verify Python 3.10 binary files. You should see multiple Python binary files, which include Pip3.10.

ls /usr/local/bin

Next, to ensure that you can run the new version of Python commands, you should add the '/usr/local/bin' directory to the system PATH and the visudo secure_path.

Run the below nano editor command to open a new file '/etc/bashrc'.

sudo nano /etc/bashrc

Add the following line to the file.

export PATH=$PATH:/usr/local/bin/

Save and exit when finished.

Now run the below command to reload the '/etc/bashrc' config file. Then verify the system PATH.

source /etc/bashrc
echo $PATH

You should now see the directory '/usr/local/bin' is added to the system PATH environment variable.

Next, run the below command to add and modify the sudoers configuration file.

sudo visudo

Add the directory '/usr/local/bin' to the 'Defaults secure_path:' option as below.

Defaults secure_path=....:/usr/local/bin

Save the file and exit the editor when finished.

Now run the Python3.10 and Pip3.10 binary via the sudo command as below.

sudo python3.10 --version
sudo pip3.10 --version

You should receive an output similar to this - Python 3.10 is installed from the source code to your Rocky Linux server.

setup python

In the next step, you'll install and configure the MariaDB Server for ERPNext.

Installing and Configuring MariaDB Server

On the default installation, the ERPNext will be using MySQL/MariaDB as the database server. The ERPNext required a specific version of MySQL/MariaDB for the installation. And the time of this writing, the latest version of ERPNext required MariaDB 10.6.

In this step, you'll install the MariaDB Server 10.6 from the official MariaDB repository. Then, you'll add configurations to your MariaDB Server and secure the MariaDB Server deployment.

Run the below command to add the MariaDB repository v10.6.

sudo curl -LsS https://r.mariadb.com/downloads/mariadb_repo_setup | sudo bash -s -- --mariadb-server-version="mariadb-10.6"

You'll receive the output something like this.

add mariadb repo

Next, run the dnf command below to install the MariaDB packages. Input y when prompted for the confirmation and press ENTER to proceed.

sudo dnf install MariaDB-server MariaDB-client

install mariadb

Also, when asked to accept the GPG key of the MariaDB repository, input y, and press ENTER.

After MariaDB Server is installed, run the below systemctl command utility to start and enable the MariaDB service.

sudo systemctl start mariadb
sudo systemctl enable mariadb

Now verify the MariaDB service via the below command. You should see that the MariaDB service is running and should be enabled, which means it will start automatically upon the bootup.

sudo systemctl status mariadb

start enable mariadb

With the MariaDB Server is running, you'll then start configuring the MariaDB as required for the ERPNext.

Open the MariaDB config file '/etc/my.cnf.d/server.cnf' using the below nano editor command.

sudo nano /etc/my.cnf.d/server.cnf

Add the following lines to the '[mysqld]' section. This will enable the barracuda format on your MariaDB. Also, you'll set up the default character-set to utf8mb4.

[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_unicode_ci

Save and exit the file when finished.

Next, open another MariaDB config file '/etc/my.cnf.d/mysql-clients.cnf' using the below nano editor command.

sudo nano /etc/my.cnf.d/mysql-clients.cnf

Add the following line to the '[mysql]' section. This will always set the character-set for the client to utf8mb4.

[mysql]
default-character-set = utf8mb4

Save the file and exit the editor.

Now run the below systemctl command to restart the MariaDB service and apply the changes.

sudo systemctl restart mariadb

Run the below command 'mariadb-secure-installation' to secure your MariaDB deployment. You'll then be asked for the configuration of the MariaDB root password, so be sure to input and repeat the new password. For the rest configurations, input Y to confirm and press ENTER.

sudo mariadb-secure-installation

With this, you've now finished the MariaDB Server installation and configuration. In the next step, you will install Redis, Nginx, and Supervisor on your Rocky Linux machine.

Installing Dependencies from Rocky Linux Repository

In this step, you'll some dependencies for the ERPNxt installation, this included the installation of Redis which will be used as session management, Nginx as the web server, Supervisor as the process management, and the Fail2ban which protects your ERPNext against brute-force attacks.

Most of the packages that you will be installing here are available by default on the Rocky Linux AppStream repository. But also you must ensure that the third-party repository such as EPEL is available on your system.

Run the below dnf command to install Redis, Nginx, Supervisor, and Fail2ban to your Rocky Linux system.

sudo dnf install redis nginx supervisor fail2ban

When prompted for confirmation, input Y and press ENTER to proceed.

Now after the package installation is finished, run the below systemctl commands to start and enable services. Then verify each service to ensure that it's running.

Start and enable the Redis service, then verify Redis to ensure it's running.

sudo systemctl start redis
sudo systemctl enable redis

sudo systemctl status redis

You'll receive an output similar to this.

verify reddis

Next, start and enabled the Nginx service, then verify Nginx to ensure that the service is running.

sudo systemctl start nginx
sudo systemctl enable nginx

sudo systemctl status nginx

You'll receive the output something like this.

verify nginx

After that, start the Supervisor service and enable it. Then, verify the Supervisor service to ensure that it's running.

sudo systemctl start supervisord
sudo systemctl enable supervisord

sudo systemctl status supervisord

Below is the output you should get on your terminal screen.

verify supervisord

And lastly, for the Fail2ban service, start and enable it via the systemctl command utility below. Then, verify the Fail2ban service to ensure that the service is running.

sudo systemctl start fail2ban
sudo systemctl enable fail2ban

sudo systemctl status fail2ban

You should now see the Fail2ban service status is running.

verify fail2ban

Now after completing this section, and verified that Redis, Nginx, Supervisor, and Fail2ban services is running. Move to the next section for installing the Node.js and Yarn package manager.

Installing Nodejs 16 and Yarn

The latest version of ERPNext is v14, which is required at least the Node.js 16 and Yarn package manager. In this step, you'll set up the Nodesource repository for Node.js v16 and add the Yarn repository for RHEL distribution. Then, you'll install both Node.js and yarn via DNF.

First, run the below command to add the Nodesource repository for the Node.js v16 for the RHEL distributions.

curl -fsSL https://rpm.nodesource.com/setup_16.x | sudo bash -

You should receive the output something like this - The script will automatically detect the version of the current RHEL distribution and add the Nodesource repository.

add nodesource repo

For the Yarn repository, run the below command to download the repository and add it to your system.

curl -sL https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo

Below is the output you should receive on your terminal.

add yarn repo

Now that both Nodesource and Yarn repository is added to your Rocky Linux system, it's time to install the Node.js and Yarn package manager via DNF.

Run the below dnf command to install Node.js and Yarn to your system. Input y when prompted for the confirmation and press ENTER to proceed.

sudo dnf install gcc-c++ make nodejs yarn

The Node.js and Yarn installation should begin.

install yarn nodejs

Also, when prompted about the GPG key for both repositories, input y and press ENTER to add the GPG key to your system.

accept gpg key

Now that the Node.js and Yarn package manager is installed, you'll next install the Wkhtmltopdf package via RPM file.

Installing Wkhtmltopdf

In this step, you'll install the Wkhtmltopdf package that will be used by ERPNext to generate PDF reports. The Wkhtmltopdf can download and installed manually via .deb file or .rpm file.

First, run the below dnf command to install dependencies for the Wkhtmltopdf package.

sudo dnf install fontconfig freetype libX11 libXext libXrender libjpeg libpng xorg-x11-fonts-75dpi xorg-x11-fonts-Type1

Input y when prompted and press ENTER to proceed.

install dependnecies

Next, run the below rpm command to download and install the Wkhtmltopdf package to your Rocky Linux system.

sudo rpm -Uvh https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6.1-2/wkhtmltox-0.12.6.1-2.almalinux9.x86_64.rpm

After the Wkhtmltopdf is installed, run the below commands to verify the installation.

The Wkhtmltopdf package provides two command line tools, the wkhtmltopdf command is used to convert an HTML page to PDF, while the wkhtmltoimage converts the HTML page to various image formats.

which wkhtmltopdf
which wkhtmltoimage
wkhtmltopdf --version
wkhtmltoimage --version

You'll receive the output similar to this - The Wkhtmltopdf package v0.12 is installed on your Rocky Linux system.

install verify wkhtmltopdf

At this point, you've finished the installation of package dependencies for ERPNext and frappeframework. This included the Python3.10, Redis, Nginx, Supervisor, Fail2ban, MariaDB Server, and the Wkhtmltopdf packages.

In the next section, you'll start the ERPNext installation. But first, you'll install and set up the frappeframework.

Installing Frappeframework via the bench

ERPNext is an open-source ERP software th