[Answer] Has anyone used the open-source ERP system ERPNext?
![[Answer] Has anyone used the open-source ERP system ERPNext?](/_next/image?url=https%3A%2F%2Flxunzzzdnokdqhipbmdf.supabase.co%2Fstorage%2Fv1%2Fobject%2Fpublic%2Fmedia%2Fcovers%2Ferpnexterp-b3283eaa.png&w=3840&q=75)
[Answer] Has anyone used the open-source ERP system ERPNext?
[Answer] Has anyone used the open-source ERP system ERPNext?
ERPNext is one of the best open-source ERP systems (another is Odoo, which is also developed in Python). Compared with Odoo, however, there is relatively less documentation available for ERPNext. This article uses V14 as an example to demonstrate how to install ERPNext and configure it for production on Ubuntu 22.04. Compared with a Docker-based installation, this approach offers better performance and stability.
1. System Requirements
1.1 Software Requirements
- Updated Ubuntu 22.04
- A user with sudo privileges
- Python 3.10+
- Node.js 16
1.2 Hardware Requirements
- 4GB RAM
- 40GB hard disk
2. Server Setup
2.1 Update system packages before installation
sudo apt-get update -y
sudo apt-get upgrade -y
2.2 Create a new user (bench user)
To avoid the risks of installing as the root user, create a dedicated user to install and manage the system. Since ERPNext is based on the Frappe Bench framework, we create a user named frappe here to indicate that it will be used for the Frappe installation. Grant this user sudo privileges.
sudo adduser [frappe-user]
usermod -aG sudo [frappe-user]
su [frappe-user]
cd /home/[frappe-user]
3. Install Required Packages
The framework depends on a range of software packages. These should be installed in advance. To speed things up, you can switch Ubuntu to a local mirror (for example, the Tsinghua University open-source mirror), and you can also configure Python's PyPI mirror accordingly. See the mirror site documentation at tuna.moe for details.
If some packages are difficult to download or install later (for example, when Frappe Framework needs to download files from GitHub), you may need to configure an accessible proxy server in the command line or install certain dependencies in advance (for example, install Ansible first to avoid slow default installation). You can configure a proxy with export http_proxy=''.
3.1 Install Git
sudo apt-get install git
3.2 Install Python
ERPNext V14 requires Python 3.10 or above.
sudo apt-get install python3-dev python3.10-dev python3-setuptools python3-pip python3-distutils
3.3 Install Python virtual environment support
One of the basic best practices when using Python is to isolate different applications with virtual environments.
sudo apt-get install python3.10-venv
3.4 Install Software Properties Common
sudo apt-get install software-properties-common
3.5 Install MariaDB
ERPNext is built on MariaDB and currently supports only MariaDB.
sudo apt install mariadb-server mariadb-client
3.6 Install Redis Server
sudo apt-get install redis-server
3.7 Install other packages
These packages are used for font management, PDFs, and other features.
sudo apt-get install xvfb libfontconfig wkhtmltopdf
sudo apt-get install libmysqlclient-dev
4. Configure the Database
4.1 Run the following command to secure and configure the database
sudo mysql_secure_installation
During the configuration process, you will see the following English prompts. Here is a line-by-line explanation:
Enter current password for root: (Enter your SSH root user password)— the current SSH root user passwordSwitch to unix_socket authentication [Y/n]: YChange the root password? [Y/n]: Y— change the password for the database root user and enter a new passwordRemove anonymous users? [Y/n] Y— remove anonymous usersDisallow root login remotely? [Y/n]: Y— disable remote login for the root user so it can log in only locallyRemove test database and access to it? [Y/n]: Y— remove the test databaseReload privilege tables now? [Y/n]: Y— reload database privileges immediately
4.2 Edit the default MySQL configuration file
sudo nano /etc/mysql/my.cnf
Add the following content at the end of the file:
[mysqld]
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
[mysql]
default-character-set = utf8mb4
4.3 Restart the database
sudo service mysql restart
4.4 Install CURL, Node, NPM, and Yarn
Install CURL
sudo apt install curl
Install Node via NVM
Due to network issues, installing NVM directly may fail. You can refer to the author's other documentation for alternative ways to install NVM.
curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
source ~/.profile
nvm install 16.15.0
Install NPM
Since Node already includes npm, the following installation step can be skipped. However, to speed up npm package installation, you can change the npm registry to a local mirror using the second command below.
sudo apt-get install npm
npm config set registry https://registry.npmmirror.com
Install Yarn and change its registry mirror
sudo npm install -g yarn
yarn config set registry https://registry.npmmirror.com
Install Frappe Bench
sudo pip3 install frappe-bench
Initialize Frappe Bench
bench init --frappe-branch version-14 frappe-bench
Enter the new Frappe Bench directory
cd frappe-bench
Modify directory permissions
Grant additional permissions to the user's home directory to ensure the software can run properly afterward.
chmod -R o+rx /home/[frappe-user]
Create a new site
Use Bench to create a new site for installing ERPNext and apps.
bench new-site [site-name]
5. Install ERPNext and Other Apps
5.1 Download all required apps
First, install the payments app required by ERPNext.
bench get-app payments
Download the ERPNext app:
bench get-app --branch version-14 erpnext
Download additional modules, such as the HR module hrms:
bench get-app hrms
5.2 Install ERPNext on the site
Install ERPNext on the site:
bench --site [site-name] install-app erpnext
Install additional modules on the site:
bench --site [site-name] install-app hrms
Set the new site as the current site and start it:
bench use [your-site]
bench start
If 127.0.0.1 cannot be found, add it to the hosts file with:
bench --site [your-site] add-to-hosts
When no port is specified, ERPNext uses port 8000 by default, and the site can then be accessed through that port.
After completing the installation above, ERPNext runs in developer mode, which means you must run bench start each time to start it, and performance is relatively low. Therefore, you can configure it for production mode with the following steps.
6. Configure ERPNext for Production
6.1 Enable the scheduler
bench --site [site-name] enable-scheduler
6.2 Disable maintenance mode
bench --site [site-name] set-maintenance-mode off
6.3 Configure the system
sudo bench setup production [frappe-user]
6.4 Configure nginx
bench setup nginx
6.5 Use Ansible to configure and start the system
You can install Ansible manually in advance to speed up configuration. After setup is complete, the site can be accessed via the default port 80.
sudo supervisorctl restart all
sudo bench setup production [frappe-user]
7. Configure SSL Certificates
In a production environment, HTTPS access is required, so SSL certificates must be configured.
7.1 Enable dns_multitenant
When this option is enabled, different sites on the same server are distinguished by domain name and can all be accessed through the default port 80.
bench config dns_multitenant on
If you need to access different sites through different ports instead (not the case in this example), you can disable the option above and configure them separately. By default, the first site uses port 80. In the following example, a new site is created and accessed through port 82:
bench config dns_multitenant off
bench new-site site2name
bench set-nginx-port site2name 82
bench setup nginx
sudo service nginx reload
7.2 Add a domain name to the site
Use the following command to add a domain name to the ERP site. When the command runs, it will prompt you to specify which ERPNext site the domain should be bound to. Enter the site name to bind the domain to that site.
bench setup add-domain [desired-domain]
7.3 Specify the certificate file paths
If you have already obtained SSL certificate files, use the following parameters to specify their locations:
--ssl-certificate [path-to-certificate]
--ssl-certificate-key [path-to-certificate-key]
For example, if the certificate and key are stored in the following paths, use:
bench setup add-domain custom.erpnext.com --ssl-certificate /etc/letsencrypt/live/erpnext.cert --ssl-certificate-key /etc/letsencrypt/live/erpnext.key
These settings can also be found in the site's site_config.json file:
"domains": [
{
"ssl_certificate": "/etc/letsencrypt/live/erpnext.cert",
"domain": "erpnext.com",
"ssl_certificate_key": "/etc/letsencrypt/live/erpnext.key"
}
],
7.5 Reconfigure nginx and restart the service
After reconfiguring nginx and reloading the service, the site can be accessed via HTTPS.
bench setup nginx
sudo service nginx reload
7.6 Other automated ways to install Let's Encrypt free SSL certificates (untested)
According to the documentation, you can also use the following commands to install and automatically renew certificates. Since my site already has a certificate installed, I have not tested this method yet. Based on the documented steps, it should be run after binding the domain to the site in the earlier steps.
sudo apt install snapd
sudo snap install core; sudo snap refresh core
# Remove any old version of certbot that may exist and reinstall it
sudo apt-get remove certbot
sudo snap install --classic certbot
sudo ln -s /snap/bin/certbot /usr/bin/certbot
# Automatic installation
sudo certbot --nginx
# Manual installation; choose either this or the automatic method above
sudo certbot certonly --nginx
# Configure automatic renewal
sudo certbot renew --dry-run
In addition to the commands above, the official documentation also mentions the following two commands as a quick way to install and renew SSL certificates:
sudo -H bench setup lets-encrypt [site-name] --custom-domain [custom-domain]
sudo bench renew-lets-encrypt
![[Thought] Many viruses you’ve probably never heard of also contain DNA, such as iridoviruses](/_next/image?url=https%3A%2F%2Flxunzzzdnokdqhipbmdf.supabase.co%2Fstorage%2Fv1%2Fobject%2Fpublic%2Fmedia%2Fcovers%2Fdna-39161584.png&w=3840&q=75)
![[Answer] What did you do on the night you checked your Gaokao score?](/_next/image?url=https%3A%2F%2Flxunzzzdnokdqhipbmdf.supabase.co%2Fstorage%2Fv1%2Fobject%2Fpublic%2Fmedia%2Fcovers%2F-e4a8ec38.png&w=3840&q=75)
![[Answer] How Can You Score 130+ on the Gaokao Math Exam?](/_next/image?url=https%3A%2F%2Flxunzzzdnokdqhipbmdf.supabase.co%2Fstorage%2Fv1%2Fobject%2Fpublic%2Fmedia%2Fcovers%2F130-157dba52.png&w=3840&q=75)