Installation Process from ERPnext Community
Python 3.6+
Node.js 12
Redis 5 (caching and real time updates)
MariaDB 10.3.x / Postgres 9.5.x (to run database driven apps)
yarn 1.12+ (js dependency manager)
pip 20+ (py dependency manager)
wkhtmltopdf (version 0.12.5 with patched qt) (for pdf generation)
cron (bench's scheduled jobs: automated certificate renewal scheduled backups)
NGINX
For my case, I’m going to create my project on Desktop’s subdirectory (ERPNext Folder).
Open the terminal by pressing: CTL + ATL+ T
Navigate into the Desktop by typing the command:
cd Desktop/
Create subfolder:
mkdir ERPNext
Install Virtual environment by:
sudo apt-get install python3-venv
Create python virtual environment:
python3 -m venv env
Install curl first:
sudo apt install curl
Download and execute the NodeSource installation script:
curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
This will:
- Add script of NodeSource signing key to your system,
- Create an apt repository file,
- Install all necessary packages and
- Refresh the apt cache.
If you need another Node.js version, for example 12.x, change the setup_14.x with setup_12.x
Once the NodeSource repository is enabled, install Node.js and npm:
sudo apt install nodejs
Check Node Version
node --version
Check npm version
npm --version
sudo npm install -g yarn
sudo apt install git python-dev redis-server
sudo apt-get install software-properties-common
If you are on Ubuntu version older than 20.04, run this before installing MariaDB:
apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8 add-apt-repository 'deb [arch=amd64,i386,ppc64el] http://ftp.ubuntu-tw.org/mirror/mariadb/repo/10.3/ubuntu xenial main'
If you are on version Ubuntu 20.04, then MariaDB is available in default repo and you can directly run the below commands to install it
sudo apt-get update
sudo apt-get install mariadb-server-10.3
During this installation you'll be prompted to set the MySQL root password.
N.B: If you are not prompted, you'll have to initialize the MySQL server setup yourself. You can do that by running the command. (Remember: only run it if you're not prompted the password during setup.)
sudo mysql_secure_installation
You will be prompted with the following commands during the process
Enter current password for root (enter for none):
Change the root password? [Y/n] y
New password:
Re-enter new password:
Remove anonymous users? [Y/n] y
Disallow root login remotely? [Y/n] y
Remove test database and access to it? [Y/n] y
Reload privilege tables now? [Y/n] y
It is really important that you remember this password, since it'll be useful later on.
sudo apt-get install libmysqlclient-dev
Now, edit the MariaDB configuration file.
sudo nano /etc/mysql/my.cnf
Add the following line to the 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
Restart MariaDB and enable it to automatically start at boot time.
sudo systemctl restart mariadb
sudo systemctl enable mariadb
Now, just restart the mysql service and and check status.
sudo service mysql restart
service mysql status
sudo apt-get install xvfb libfontconfig wkhtmltopdf
(Activate the virtual environment with the command: source env/bin/activate)
sudo apt -y install nginx redis-server
sudo systemctl start nginx
sudo systemctl enable nginx
sudo systemctl start redis-server
sudo systemctl enable redis-server
pip3 install frappe-bench
Confirm the bench installation by checking version
bench --version
bench init frappe-bench
While installing you might see some errors run the following command to install the dependency in order to avoid the error.
sudo apt-get install gcc python3-dev
Create a new Frappe site.
bench new-site <site_name> --db-name <site_database_name>
The above command will prompt you for the MySQL root password. Provide the password which you have set for the MySQL root user earlier. It will also ask you to set a new password for the administrator account. You will need this password later to log into the administrator dashboard.
While creating the site you will be prompted to provide mysql password. If it prevents follow the following steps:
Database Login Issues
In some cases Database may not login, to rectify the issue Please Follow below steps
sudo nano /etc/mysql/my.cnf
Add the following lines at the end:
[mysqld]
skip-grant-tables
Then Restart the service
sudo service mysql restart
Login to Mysql & follow the command
mysql -u root
use mysql
SELECT * FROM mysql.user WHERE user = 'root';
(Look at the top to determine whether the password column is called password or authentication_string)
UPDATE mysql.user SET authentication_string = PASSWORD('123456’) where user = 'root' and host = 'localhost'; - Use the proper password column from above
SELECT User, Host, plugin FROM user;
(if Plugin is not mysql_native_password, then set the plugin by the below command)
UPDATE user SET plugin='mysql_native_password' WHERE User='root';
FLUSH PRIVILEGES;
exit;
Remove the skip-grant-tables from /etc/mysql/my.cnf and restart the service & it's Done
bench get-app erpnext https://github.com/frappe/erpnext
bench --site erp.testsite install-app erpnext
You can start the application immediately to check if the application installed successfully.
bench start
*You might face the error saying: Could not start up: Error in setup
In such case:
- Make sure you didn't miss any dependencise.
cd /Desktop/frappe-bench
sudo chown -R user:user *
(For my case I’ve applied the following command since my user is mhfahad)
sudo chown -R mhfahad:mhfahad *
bench start
Creating a custom Module
Here I'm going to create a module named Alesha Products
Navigate to the project
bench new-app bigtech_product
This will ask you app specific information along with some default values
Once the installation is complete, you will have to install the app to the site. By default the site doesn't know the app details.
In order to install the application to the site you need to apply the following command.
bench --site <site_name> install-app <app_or_module_name>
In order to check installed apps of a particular site:
bench --site <site_name> list-apps
There are several site commands. To see all site commands.
bench --site <site_name> --help
The custom app/module is available in the site. Now we have to create doctype for the application to use.
In order to customize the site we need to run the site with enabled developer mode. To do that type:
bench --site <site_name> set-config developer_mode 1
In simple, DocType is the database table name of Frappe Framework. You will be directly interecting with database tabels using Frappe's DocType.
In our custom app/ module we will create two doctypes.
- Vendors
- Alesha Products
While in Desk, type "doctype" in the search bar and select the DocType List option. You will be navigated to the DocType list where you will see a bunch of DocTypes. These are the DocTypes that are bundled with the framework.
The first doctype we will create is Vendors.
To create it, click on New.
- Enter Name as Alesha Vendors.
- Select Library Management in Module
- Add the following fields in the Fields table:
Image(Attach Image)
Full Name (Data)
Eamil (Data)
Contact (Text Editor)
Address (Data)
Bank Name (data)
Bank Account Name (data)
Bank Account Number (data)
Route (data)
Vendor Type (Select) Enter options: Shop and Company (Type Shop, hit enter, then Type Company)
-
To save the form, Click save button
-
add the following text to the auto naming field in the bottom so that the vendor name is unique throughout the list.
BGT.VEN.#####
-
In Form Settings section add the insert image to the text box. This lets frappe know which field of the table is image field so that it can handle that field in such way.
-
In View Settings section, add which form field name you want to name the html view title name
For my purpose I've used full_name field
-
You can also restict the permission to different user roles from the Permission Rules section.
Here I've added Business Developer who has the permission to read, write, create and delete permission. On the contrary, Operations role will have only read permission.
-
Now save again. Reload the page by selecting Reload option from three dot button beside the save button.
-
Go to vendor List
-
Create Vendor
You will see that vandor with your given information has shown in the vendor list.
By Checking the Database You can also see new database table of named 'tabVendor'
- Add row to vendor form fields table.
- Make the type Coumn Break
- Drag it to middle of the fields table rows.
- Save changes.
- Now go to add new vendor. You will see the long for is now splitted into two columns.
- We can also seperate a section of form to new sectin. In that case we have to add another row to the table as set the type Section Break
- Than drag the row before the row where you want to break the section.
- Go to Doctype List.
- press + add DocType blue Button
- Enter Doctype Name
- Add Module Name
- Check Is Submittable Below Module selection text input. (This add three events to the form to save it)
- Add desired fields
- Modify Naming, Form Settings, View Settings, Permission Rules
- Save the form
- Check the "Has Web View", Allow Guest to View, Index Web Pages for Search
- Add your DocType name into the Route input field e.g. Mart Product as mart_product.
- Add a new row to the Form Fields table named Route
- Make the field Hidden from row edit menu since it will be auto generated.
- Save Changes.
- Type workspace at searchbox and navigate to the Workspace List.
-
Enter your Module Name that you want to call within.
-
Select the Module for the Module list
-
Select Category
-
Enter Icon name that you want to represent your app or leave blank
-
leave Onboarding blank
-
check Is Standared from the right section
-
Give Dashboards sectionlabel a name and add chart to teh charts row.
-
Add Module specific all doctypes to the shortcut section and link them (The System will suggest all of the names, No need to memorise or else.)
-
Add Link Cards similarly.
- Save and reload.
- Now go to the admin home page.
- Make a Hard Refreash or press CTL + SHIFT + R
You can see your Custom Module at the Left side of all module lists with your Given name and Icon along with
Standared Process and best practice but slower.
bench switch-to-branch version-13 frappe erpnext --upgrade
Please use this for production server
This needs to be nevigated into the app of the project.
git pull upstream version-13
Preferred Process only for development server.
bench get-app --branch=version-13 frappe
bench get-app --branch=version-13 erpnext
N.B: Please do not use this in production server