Last active
September 5, 2024 18:46
-
-
Save drthilina/d158032bed800c51f94a0e2db4267adf to your computer and use it in GitHub Desktop.
Install ERPNext V13 on Ubuntu 20.04 LTS || Production
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Install ERPNext V13, FRAPPE-BENCH 13 on Ubuntu 20.04 and configure for production Environment | |
# Install GIT | |
$ apt install -y git | |
# Ubuntu update and upgrade packages | |
$ apt update -y && apt upgrade -y | |
# Install Python 3.8 and dependencies | |
$ sudo apt install -y python3-dev python3-setuptools python3-pip python3.8-venv software-properties-common curl | |
# Install MariaDB | |
$ curl -LsS -O https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | |
$ sudo bash mariadb_repo_setup --mariadb-server-version=10.6 | |
$ sudo apt install -y mariadb-server mariadb-client | |
# Secure MariaDB Installation | |
$ mysql_secure_installation | |
Setup <your_root_password> and proceed forward with "y + Enter" | |
# Add Configuration parameters to MariaDB relevant for Frappe framework | |
$ nano /etc/mysql/my.cnf | |
# This will open mariadb main config file, add the following to end | |
[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 | |
[mysql] | |
default-character-set = utf8mb4 | |
# Save and exit | |
# Restart MariaDB service | |
$ systemctl restart mariadb | |
# Login to MYSQL to create User and Database for FRAPPE framework to access | |
$ mysql -u root -p | |
>>> CREATE USER 'erpnext'@'localhost' IDENTIFIED BY 'erpnext'; | |
>>> GRANT ALL PRIVILEGES ON *.* TO 'erpnext'@'localhost' WITH GRANT OPTION; | |
>>> CREATE DATABASE erpnext; | |
>>> USE erpnext; | |
>>> FLUSH PRIVILEGES; | |
>>> EXIT; | |
$ service mysql restart | |
# Install Redis Server | |
$ apt install -y redis-server | |
# Install Node.js 14.x | |
$ sudo apt -y install dirmngr apt-transport-https lsb-release ca-certificates | |
$ curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash - | |
$ sudo apt -y install nodejs | |
$ node --version | |
v14.x | |
# NPM is auto installed, do update and upgrade. | |
$ apt update -y && apt upgrade -y | |
# Install YARN | |
$ npm install -g yarn | |
# Install WKHTMLTOPDF 0.12.6 (0.12.5 version will not render Letterhead headers and footers) | |
$ apt install -y xvfb libfontconfig | |
$ wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.focal_amd64.deb | |
$ sudo apt -y install ./wkhtmltox_0.12.6-1.focal_amd64.deb | |
# Check WKHTMLTOPDF versions | |
$ wkhtmltopdf --version | |
wkhtmltopdf 0.12.6 (with patched qt) | |
# Add non-root user for the FRAPPE framework | |
$ adduser frappe | |
<frappe_password> | |
$ usermod -aG sudo frappe | |
$ apt update -y && apt upgrade -y | |
# Log in as the non-root user | |
$ su frappe | |
# navigate in to the "frappe" user home directory | |
$ cd | |
# Install frappe-bench via pip | |
$ sudo -H pip3 install frappe-bench | |
# check bench version | |
$ bench --version | |
# Take ownership of home directory | |
$ sudo chown frappe -R /home/frappe | |
# Install cron for managing scheduling | |
$ sudo apt install cron -y | |
# Test Database connection | |
$ mysql -u erpnext -p | |
default password is 'erpnext' | |
# After testing connection, exit mysql prompt >>> EXIT; | |
# Initialize a frappe-bench working Directory | |
# bench init /home/frappe/frappe-bench --frappe-path https://github.com/frappe/frappe --frappe-branch version-13 | |
$ bench init frappe-bench --frappe-branch version-13 | |
# If you run in to a problem "No Directory 'install', or "yarn install", or conflicts, do the following and repeat above step | |
$ sudo apt remove cmdtest | |
$ sudo apt remove yarn | |
$ sudo yarn install --ignore-engines | |
$ sudo npm install -g yarn | |
# Navigate in to frappe-bench directory, except for "bench init" all other commands must happen from this directory | |
$ cd frappe-bench | |
# Check bench instance | |
$ bench start | |
# Goto <ip4>:8000 and will show a not found error, but this means frappe-bench initialization was successful | |
# press ctrl + C to stop and go back to prompt | |
# Create a new site | |
$ bench new-site testing_site --admin-password '<admin_password>' --mariadb-root-username erpnext --mariadb-root-password 'erpnext' | |
# Let bench know the site can be used | |
$ bench use testing_site | |
# Test bench instance again | |
$ bench start | |
# Goto <ip4>:8000 and it should show a wizard, do not proceed forward | |
# press ctrl + C to stop and go back to prompt | |
# Get bench app from GITHUB | |
$ bench get-app erpnext https://github.com/frappe/erpnext --branch version-13 | |
# Install ERPNext v13 in to the site | |
$ bench --site testing_site install-app erpnext | |
# Test bench instance again | |
$ bench start | |
# Goto <ip4>:8000 and it should show a wizard, you may proceed forward to complete the wizard | |
# Once it is complete, press ctrl + C to stop and go back to prompt | |
# ====================== Setting up for production =========================== | |
# Automated setup for ERPNext for production | |
$ sudo bench setup production frappe --yes | |
# If you are lucky everyting will go smooth, for me redis server configuration fails | |
# We need to manually add the redis configuration. | |
# make sure you are in frappe home (~) directory | |
$ cd frappe-bench/config | |
# Run the script using redis-server command | |
$ redis-server redis_cache.conf | |
# Everything shoud be okay, press "ctrl + c" to cancel and go back to prompt | |
# Try production setup again, this time it should go through | |
$ sudo bench setup production frappe --yes | |
# check output for | |
# supervisorctl reread | |
# supervisorctl update | |
# nginx -t | |
# several outputs for frappe-bench... should appear | |
# Check if other produciton environment tools are running | |
$ systemctl list-unit-files | grep 'fail2ban\|nginx\|supervisor' | |
Output | |
fail2ban.service enabled | |
nginx.service enabled | |
supervisor.service enabled | |
# Install SNAP for Centbot installation, this is for SSL | |
$ sudo apt install snapd -y | |
# For good measures lets reboot | |
$ sudo reboot now | |
# Log in as non-root user | |
$ login as frappe | |
# Install SNAP core etc. | |
$ sudo snap install core; sudo snap refresh core | |
# Install certbot | |
$ sudo snap install --classic certbot | |
# Create symbolic link for Certbot (explained in lets-encrypt instructions) | |
$ sudo ln -s /snap/bin/certbot /usr/bin/certbot | |
# Navigate to frappe-bench folder | |
$ cd frappe-bench | |
# Turn on Multitenant in frappe-bench | |
$ bench config dns_multitenant on | |
# Finally get certification (You must have a domain name, else will not work) | |
$ sudo bench setup lets-encrypt testing_site | |
# The following commands will help WKHTMLTOPDF to correctly render PDF outputs | |
# | |
# Navigate to ~/frappe-bench/sites/<your_site> | |
$ cd ~/frappe-bench/sites/testing_site | |
# Adding the host name to the site_config.json (manually) | |
$ nano site_config.json | |
# add "hostname": "https://<your_domain_name>", below "db_type" | |
"hostname": "https://<your_domain_name>" | |
# Save and exit | |
# cd to frappe-bench | |
# below will add "hostname" to the site_config.json | |
# another method | |
# bench --site testing_site set-config hostname “https://<your_domain_name>” | |
$ bench setup nginx | |
$ sudo systemctl restart nginx | |
# For good measure | |
$ sudo reboot now |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment