bench --site [my_site] console
from frappe.model.meta import trim_tables
trim_tables()
bench --site [my_site] console
from frappe.model.meta import trim_tables
trim_tables()
Thanks to GEOFFREY KARANI for his excellent guidelines in
https://codewithkarani.com/2022/08/18/install-erpnext-version-14
==================================================================================
The below prerequisites are advised in order to get an optimal functionality of ERPNext on your server.
sudo apt-get update -y
sudo apt-get upgrade -y
In linux, the root user processes escalated privileges to perform any tasks within the system. This is why it is not advisable to use this user on a daily basis. We will create a user that we can use, and this will be the user we will also use as the Frappe Bench User.
sudo adduser [frappe-user]
usermod -aG sudo [frappe-user]
su [frappe-user]
cd /home/[frappe-user]
Ensure you have replaced [frappe-user] with your username. eg. sudo adduser frappe
A software like ERPNext, which is built on Frappe Framework, requires a number of packages in order to run smoothly. These are the packages we will be installing in this step.
sudo apt-get install git
ERPNext version 14 requires Python version 3.10+. This is what we will install in this step.
sudo apt-get install python3-dev python3.10-dev python3-setuptools python3-pip python3-distutils
A virtual environment helps in managing the dependencies for one software at one place, without having to interfere with other sections in the computer or server in which the software is running.
sudo apt-get install python3.10-venv
Software Properties Common will help in repository management.
sudo apt-get install software-properties-common
ERPNext is built to naively run on MariaDB. The team is working to have the same working on PostgreSQL, but this is not ready yet.
sudo apt install mariadb-server mariadb-client
sudo apt-get install redis-server
ERPNext functionality also relies on other packages we will install in this step. These will load fonts, PDFs, and other resources to our instance.
sudo apt-get install xvfb libfontconfig wkhtmltopdf
sudo apt-get install libmysqlclient-dev
sudo mysql_secure_installation
When you run this command, the server will show the following prompts. Please follow the steps as shown below to complete the setup correctly.
sudo nano /etc/mysql/my.cnf
Add the following block of code exactly as is:
[mysqld]
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
[mysql]
default-character-set = utf8mb4
sudo service mysql restart
sudo apt install curl
curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
source ~/.profile
nvm install 16.15.0
sudo apt-get install npm
sudo npm install -g yarn
sudo pip3 install frappe-bench
bench init --frappe-branch version-14 frappe-bench
cd frappe-bench
This will give the bench user execution permission to the home directory.
chmod -R o+rx /home/[frappe-user]
A site is a requirement in ERPNext, Frappe and all the other apps we will be needing to install. We will create the site in this step.
bench new-site [site-name]
The first app we will download is the payments app. This app is required when setting up ERPNext.
bench get-app payments
Next, we will download ERPNext app
bench get-app --branch version-14 erpnext
Download any other app you may be interested in in a similar manner. For instance, if you need the Human Resource app to be installed, use the following command.
bench get-app hrms
bench --site [site-name] install-app erpnext
Install all the other apps you downloaded in the same way. For example, if you downloaded the human resource app, use the below command to install it.
bench --site [site-name] install-app hrms
We have successfully setup ERPNext version 14 on ubuntu 22.04. You can start the server by running the below command:
bench start
If you didn’t have any other ERPNext instance running on the same server, ERPNext will get started on port 8000. If you visit [YOUR SERVER IP:8000], you should be able to see ERPNext version 14 running.
Please note that instances which are running on develop mode, like the one we just setup, will not get started when you restart your server. You will need to run the bench start command every time the server restarts.
In the below steps, we will learn how to deploy the production mpde.
bench --site [site-name] enable-scheduler
bench --site [site-name] set-maintenance-mode off
sudo bench setup production [frappe-user]
bench setup nginx
sudo supervisorctl restart all
sudo bench setup production [frappe-user]
If you are prompted to save the new/existing config file, respond with a Y.
When this completes doing the settings, your instance is now on production mode and can be accessed using your IP, without needing to use the port.
This also will mean that your instance will start automatically even in the event you restart the server.
# update
cd ~/frappe-bench bench update # update to major release ex. v12 --> v13 # nodejs >= 10 required cd ~ curl -sL https://deb.nodesource.com/setup_10.x -o nodesource_setup.sh sudo bash nodesource_setup.sh sudo apt install nodejs nodejs -v # now upgrade cd ~/frappe-bench bench switch-to-branch version-13-beta frappe erpnext --upgrade bench update --patch bench migrate bench update --build
First disable the swap and delete it
sudo swapoff /swapfile
sudo rm /swapfile
Create new swap space of size 16 GB (16 * 1024 = 16384). bs
is the block size. Basically bs * count = bytes to be allocated (in this case 16 GB). Here bs = 1M (M stands for mega, so we are assigning 1MB block size) and we are allocating 16384 * 1MB (=16GB) to swap.
sudo dd if=/dev/zero of=/swapfile bs=1M count=16384
Give it the read/write permission for root
sudo chmod 600 /swapfile
Format it to swap
sudo mkswap /swapfile
Turn on swap again
sudo swapon /swapfile
Now reboot the PC for the above changes to take place.
On a clean fresh server on “root” login make sure to add a user for the ERPNext install…
(Obviously replace [USER] with your username everywhere in this posting)
adduser frappe
usermod -aG sudo frappe
Then while still logged in as root, update the system to the latest packages…
apt-get update
apt-get upgrade
Now, logout as the root user and login with the new user you just created. Perform the following steps:
export LC_ALL=C.UTF-8
sudo apt install git libffi-dev python3-minimal build-essential python3-distutils python3-setuptools python3-pip python3-testresources libssl-dev wkhtmltopdf redis
Nest we need to fix a potential problem in the redis config file:
sudo vi /etc/redis/redis.conf
When the editor is open, search for: bind 127.0.0.1 ::1
and edit our the 2 colons and the 1 so it looks like bind 127.0.0.1
then save the file.
wget https://raw.githubusercontent.com/frappe/bench/develop/install.py
sudo python3 install.py --verbose --production --user [USER] --mariadb-version 10.5 --frappe-branch version-13 --erpnext-branch version-13
frappe.ui.form.on("Journal Entry", {
after_save: function(frm) {
frm.doc.title = frm.doc.name;
}
});