Thursday, December 12, 2024

 How to install ERPNext v15 on Linux Ubuntu (step-by-step instructions)


sudo apt install openssh-server -y

sudo apt-get update -y && sudo apt-get upgrade -y

sudo apt install locate

sudo adduser frappe

sudo usermod -aG sudo frappe

su frappe

cd /home/frappe

***************************************

sudo add-apt-repository ppa:deadsnakes/ppa

# ModuleNotFoundError: No module named 'apt_pkg'

sudo apt install --reinstall python3-apt

***************************************

Setting Time Zone: timedatectl set-timezone "Asia/Kolkata"

Required Packages 

Install Git: sudo apt-get install git -y

Install fail2ban :sudo apt install fail2ban -y

Python Librarues: sudo apt-get install python3-dev python3.10-dev python3-setuptools python3-pip python3-distutils -y

                : sudo apt install python3.10-venv -y

Install nginx:      sudo apt install nginx -y

                    sudo service nginx status

        touch  /var/log/nginx/access.log 

        touch /var/log/nginx/error.log

nano /etc/nginx/conf.d/frappe-bench.conf
line 103  delete "main"  text

Install supervisor: sudo apt-get install supervisor -y

  : sudo service supervisor status

Common Software Properties: sudo apt-get install software-properties-common -y

Install Maria DB: sudo apt install mariadb-server mariadb-client -y

Redis 6: sudo apt-get install redis-server -y

Install PDF Converter: sudo apt-get install xvfb libfontconfig wkhtmltopdf -y

Server Setup: sudo apt-get install libmysqlclient-dev -y

: sudo mysql_secure_installation

: MySQL root password: <admin123>

: sudo nano /etc/mysql/my.cnf

Code to add to my.cnf: 

[mysqld]

character-set-client-handshake = FALSE

character-set-server = utf8mb4

collation-server = utf8mb4_unicode_ci


[mysql]

default-character-set = utf8mb4


restart the server: sudo service mysql restart

Node.js 18: sudo apt install curl

: curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash

: source ~/.profile

: nvm install 18

: sudo apt-get install npm -y

yarn 1.12+: sudo npm install -g yarn

Installing Frappe Bench : sudo pip install frappe-bench

Initiating the latest bench: bench init --frappe-branch version-15 frappe-bench 

: cd frappe-bench/

: chmod -R o+rx /home/frappe

: bench start


Open Another Terminal and go to frappe-bench directory

su frappe

cd /home/frappe/frappe-bench

Adding a new website: bench new-site demoerpnext.meditechnos.com

MySQL root password: <admin123>

Set Administrator password:  <admin123>

Re-enter Administrator password:  <admin123>


#sudo ln -s /home/frappe/frappe-bench/config/supervisor.conf /etc/supervisor/conf.d/frappe-bench.conf

sudo nano /etc/supervisor/supervisord.conf

; supervisor config file


[unix_http_server]

file=/var/run/supervisor.sock   ; (the path to the socket file)

chmod=0700                       ; sockef file mode (default 0700)

chown=frappe:frappe       ;  chown=your_erp_user:your_erp_user

[group:frappe]



Getting the Apps

ERPNEXT-15  : bench get-app --branch version-15 erpnext

Payments:     bench get-app --branch version-15 payments

HRMS:         bench get-app --branch version-15 hrms

Healthcare :  bench get-app --branch version-15-beta healthcare

Chat App:     bench get-app chat

#India Compliance  : bench get-app --branch version-15-beta https://github.com/resilient-tech/india-compliance.git

#                    bench get-app --branch version-15 https://github.com/resilient-tech/india-compliance.git


Go to First Terminal 

Stop the running bench : ctrl+c

Set the website: bench use demoerpnext.meditechnos.com

Start the bench again: bench start


Go to second terminal 

Install ERPNext-15   : bench --site demoerpnext.meditechnos.com install-app erpnext

Install Payments app : bench --site demoerpnext.meditechnos.com install-app payments

Install HRMS : bench --site demoerpnext.meditechnos.com install-app hrms

Install healthcare   : bench --site demoerpnext.meditechnos.com install-app healthcare  

# Error: No module named 'frappe.core.doctype.medical_department'

#Install India Compliance: bench --site demoerpnext.meditechnos.com install-app india_compliance

#Uninstall india_compliance App: bench --site demoerpnext.meditechnos.com uninstall-app india_compliance


List of installed app:  bench --site demoerpnext.meditechnos.com list-apps


Setup Production mode: 

Go to first terminal 

Stop the bench: ctrl+c

Enable Scheduler: bench --site demoerpnext.meditechnos.com enable-scheduler

Disable Mnt mode: bench --site demoerpnext.meditechnos.com set-maintenance-mode off

Setup Production: sudo bench setup production frappe

                : sudo bench setup role fail2ban

NGINX Setup: bench setup nginx

Restart All Services: sudo supervisorctl restart all

Setup Production once again: sudo bench setup production frappe

Open the ports: sudo ufw allow 22,25,80,143,443,3306, 3022,3389,8000/tcp 

Apply Firewall : sudo ufw enable / sudo ufw disable

 your server http://[IP-address]:80 and you will have a fresh new installation of ERPNext ready to be configured!

User name: administrator

password: admin123

 Custom Domain & SSL Setup

cd /home/[frappe-user]/frappe-bench/ bench config dns_multitenant on bench setup add-domain [subdomain.yourdomain.com] --site [site-name] bench setup nginx sudo service nginx reload sudo snap install core sudo snap refresh core sudo snap install --classic certbot sudo ln -s /snap/bin/certbot /usr/bin/certbot sudo certbot --nginx

  

[Guide] How to install ERPNext v15 on Linux Ubuntu (step-by-step instructions)


v15 Full Changelog: https://github.com/frappe/frappe/issues/22834 
v15 Release Announcement: Frappe and ERPNext v15 release

Table of Contents:

  • Step 1: Server Setup
  • Step 2: Install Required Packages
  • Step 3: Configure MySQL Server
  • Step 4: Install CURL, Node, NPM, Yarn
  • Step 5: Install Frappe Bench
  • Step 6: Install ERPNext and other Apps
  • Step 7: Setup Production Server
  • Step 8: Custom Domain & SSL Setup

PRE-REQUISITES:

  • Operating System: Linux Ubuntu 22.04 LTS
  • Minimum Recommended Hardware: 2 CPU | 4 GB RAM | 20 GB Disk
  • Root shell access to the server (via SSH)

:one: SERVER SETUP


1.1 Login to the server as root user

1.2 Setup correct date and timezone (important step as it impacts ERPNext usage)

Check the server’s current timezone

date

Set correct timezone as per your region

timedatectl set-timezone "Asia/Kolkata"

1.3 Update & upgrade server packages

sudo apt install openssh-server -ysudo apt-get update -y sudo apt-get upgrade -y

1.4 Create a new user
We create this user as a security measure to prevent root user access.
This user will be assigned admin permissions and will be used as the main Frappe Bench user

sudo adduser [frappe-user] usermod -aG sudo [frappe-user] su [frappe-user] cd /home/[frappe-user]/

Note: Replace [frappe-user] with your username. Eg. sudo adduser myname

For some cloud providers like AWS & Azure, you wont’t have root password access so you can simply run sudo -i when you login to the server using the default user (eg. ubuntu in AWS)


:two: INSTALL REQUIRED PACKAGES


Frappe Bench and ERPNext requires many packages to run smoothly. In this step we will install all the required packages for the system to work correctly.

Note: During the installation of these packages the server might prompt you to confirm if you want to continue installing the package [Y/n]. Just hit “y” on your keyboard to continue.

2.1 Install GIT

sudo apt-get install git -y

Check if GIT is correctly installed by running git --version

2.2 Install Python

sudo apt-get install python3-dev python3.10-dev python3-setuptools python3-pip python3-distutils -y

2.3 Install Python Virtual Environment

sudo apt-get install python3.10-venv

Check if Python is correctly installed by running python3 -V

2.4 Install Software Properties Common (for repository management)

sudo apt-get install software-properties-common

2.5 Install MariaDB (MySQL server)

sudo apt install mariadb-server mariadb-client -y
If Needssudo mysql -u root use mysql; SET PASSWORD FOR 'root'@'localhost' = PASSWORD('welcome'); FLUSH PRIVILEGES; exit

Check if MariaDB is correctly installed by running mariadb --version

2.6 Install Redis Server

sudo apt-get install redis-server -y 2.7 Install other necessary packages (for fonts, PDFs, etc) sudo apt-get install xvfb libfontconfig wkhtmltopdf -y sudo apt-get install libmysqlclient-dev -y

:three: CONFIGURE MYSQL SERVER


3.1 Setup the server

sudo mysql_secure_installation

During the setup process, the server will prompt you with a few questions as given below. Follow the instructions to continue the setup;

  • Enter current password for root: (Enter your SSH root user password)
  • Switch to unix_socket authentication [Y/n]: Y
  • Change the root password? [Y/n]: Y
    It will ask you to set new MySQL root password at this step. This can be different from the SSH root user password.
  • Remove anonymous users? [Y/n] Y
  • Disallow root login remotely? [Y/n]: N
    This is set as N because we might want to access the database from a remote server for using business analytics software like Metabase / PowerBI / Tableau, etc.
  • Remove test database and access to it? [Y/n]: Y
  • Reload privilege tables now? [Y/n]: Y

3.2 Edit the MySQL default config file

sudo vim /etc/mysql/my.cnf

Add the below code block at the bottom of the file;

[mysqld] character-set-client-handshake = FALSE character-set-server = utf8mb4 collation-server = utf8mb4_unicode_ci [mysql] default-character-set = utf8mb4

If you don’t know how to use VIM:

  • Once the file is open, hit “i” key to start editing the file.
  • After you’re done editing the file hit “Esc + :wq” to save the file

3.3 Restart the MySQL server (for the config to take effect)

sudo service mysql restart

:four: Instal CURL, Node, NPM and Yarn


4.1 Install CURL

sudo apt install curl

4.2 Install Node

curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash source ~/.profile nvm install 18

4.3 Install NPM

sudo apt-get install npm -y

4.4 Install Yarn

sudo npm install -g yarn

Check if Node is correctly installed by running node --version


:five: INSTALL FRAPPE BENCH


5.1 Install Frappe Bench

sudo pip3 install frappe-bench

Check if Frappe Bench is correctly installed by running bench --version

5.2 Initialize Frappe Bench

bench init --frappe-branch version-15 frappe-bench

5.3 Go to Frappe Bench directory
This will be the main directory from where we will be running all the commands.
The full path of this directory will be: /home/[frappe-user]/frappe-bench/

cd frappe-bench/

5.4 Change user directory permissions
This will allow execution permission to the home directory of the frappe user we created in step 1.4

chmod -R o+rx /home/[frappe-user]/

5.5 Create a New Site
We will use this as the default site where ERPNext and other apps will be installed.

bench new-site <site1.local.com> MySQL root password:

:six: Install ERPNext and other Apps


Finally, we’re at the last stage of the installation process!

6.1 Download the necessary apps to our server
Download the payments apps . This app is required during ERPNext installation

bench get-app payments

Download the main ERPNext app

bench get-app --branch version-15 erpnext

Download the HR & Payroll app (optional)

bench get-app hrms

Check if all the apps are correctly downloaded by running bench version --format table

6.2 Install all the Apps

Install the main ERPNext app

bench --site site1.local install-app erpnext

Install the HR & Payroll app (optional)

bench --site site1.local install-app hrms

Note: You might get some warnings / error messages while trying to install apps on the default site. These messages can be ignored and you can proceed further.


:seven: SETUP PRODUCTION SERVER


7.1 Enable scheduler service

bench --site site1.local enable-scheduler

7.2 Disable maintenance mode

bench --site site1.local set-maintenance-mode off

7.3 Setup production config


sudo bench setup role fail2bansudo bench setup production [frappe-user]

7.4 Setup NGINX web server

bench setup nginx

7.5 Final server setup

sudo apt-get install supervisorsudo service supervisor statussudo supervisorctl restart all sudo bench setup production [frappe-user] bench setup role fail2ban  sudo bench setup role fail2ban

When prompted to save new/existing config files, hit “Y”

:tada: Ready to Go!

You can now go to your server [IP-address]:80 and you will have a fresh new installation of ERPNext ready to be configured!

If you are facing any issues with the ports, make sure to enable all the necessary ports on your firewall using the below commands;

sudo ufw allow 22,25,143,80,443,3306,3022,8000/tcp sudo ufw enable

:eight: : Custom Domain & SSL Setup

For SSL configuration, you can run the following commands;

Before you begin, add an A record on your domain DNS and point it to the ERPN server IP address.

cd /home/[frappe-user]/frappe-bench/ bench config dns_multitenant on bench setup add-domain [subdomain.yourdomain.com] --site [site-name] bench setup nginx sudo service nginx reload sudo snap install core sudo snap refresh core sudo snap install --classic certbot sudo ln -s /snap/bin/certbot /usr/bin/certbot sudo certbot --nginx

On terminal prompt, follow the instructions and select the correct site number and trying access your site on https:// from the custom domain you just added.  

username: Administrator 

passwordadmin <given password>

You now have a fully production ready setup of Frappe & ERPNext on your server!

Thanks,


https://discuss.frappe.io/t/guide-how-to-install-erpnext-v15-on-linux-ubuntu-step-by-step-instructions/111706