ERPNext 13 install on Debian 10
apt update
apt upgrade
Reboot if needed.
Upgrade to Python 3.8
For ERPNext version 13, Python 3.8 is needed (3.9 is not fully compatible). Debian 10 only provide Python 3.7, so it is necessary to upgrade to the latest 3.8.x version of Python.
install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libsqlite3-dev libreadline-dev libffi-dev curl libbz2-dev
ownload the latest release’s source code from the Python download page with wget or curl . At the time of writing this article, the latest release is 3.8.13:
curl -O https://www.python.org/ftp/python/3.8.13/Python-3.8.13.tar.xz
Extract the tarball:
tar -xvf https://www.python.org/ftp/python/3.8.13/Python-3.8.13.tar.xz
cd Python-3.8.2
./configure --enable-optimizations
The script performs a number of checks to make sure all of the dependencies on your system are present. The --enable-optimizations option will optimize the Python binary by running multiple tests, which will make the build process slower.
Run make to start the build process (Modify the -j to correspond to the number of cores in your processor. You can find the number by typing nproc.):
make -j 2
Once the build is done, install the Python binaries by running the following command as a user with sudo access. Do not use the standard make install as it will overwrite the default system python3 binary:
sudo make altinstall
Python 3.8 is installed on your Debian system and ready to be used. You can verify it by typing:
python3.8 --version
Output:
Python 3.8.13
Install Prerequisite packages via apt
apt -y install git vim libffi-dev python-pip python3-distutils python-dev libssl-dev wkhtmltopdf
Patch qt of wkhtmltopdf
apt install wget
apt install libxrender1 libxext6 xfonts-75dpi xfonts-base fontconfig
# wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.buster_amd64.deb
# dpkg -i wkhtmltox_0.12.6-1.buster_amd64.deb
rm wkhtmltox_0.12.6-1.buster_amd64.deb
apt -y install nodejs npm redis-server
npm install -g yarn
Install nginx
apt -y install nginx
Setup environment
sudo localectl set-keymap us && sudo localectl set-locale LANG=en_US.utf8
sudo vi /etc/environment
add the following content:
LC_ALL=en_US.UTF-8
LC_CTYPE=en_US.UTF-8
LANG=en_US.UTF-8
save file and reboot system.
Install git, python, and redis
apt install git python-dev python-pip redis-server
Install Supervisor and set it to start automatically:
# apt install supervisor
# systemctl enable --now supervisor
Install MariaDB
apt-get install software-properties-common
apt-get install mariadb-server-10.3
During this installation you'll be prompted to set the MySQL root password. If you are not prompted, you'll have to initialize the MySQL server setup yourself. You can do that by running the command:
mysql_secure_installation
Example
root@erpnext1-deb10-stg:/home/erpnextuser# mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none):
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
Set root password? [Y/n] Y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!
By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n] Y
... Success!
Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] Y
... Success!
By default, MariaDB comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] Y
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] Y
... Success!
Cleaning up...
All done! If you've completed all of the above steps, your MariaDB
installation should now be secure.
Thanks for using MariaDB!
Mariadb must be 10.3 or newer.
Apt update and install additional Mariadb files if missing:
apt update && apt install mariadb-server libmariadb-dev-compat libmariadb-dev
also need the MySQL database development files.
apt-get install mariadb-client-10.3
Edit the MariaDB configuration file.
vi /etc/mysql/my.cnf
add this configuration
[mysqld]
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
[mysql]
default-character-set = utf8mb4
Save file.
Configure MariaDB for use with Frappe-Bench
Edit your mariadb.cnf file to enable the Baracuda engine for innodb:
# vi /etc/mysql/mariadb.conf.d/50-server.cnf
- Insert the following below the [mysqld] block:
-
[mysqld]
innodb-file-format=barracuda
innodb-file-per-table=1
innodb-large-prefix=1
Insert the following below the [mysql] block:
[mysql]
default-character-set = utf8mb4
Save file and exit.
restart the mysql/mariadb service and you are good to go.
service mysql restart
or for mariadb
service mariadb restart
or
systemctl restart mariadb
Prepare database for ERPNext db
mysql -u root -p
Create a database and grant users all permissions to manage the database.
CREATE USER 'erpnext'@'localhost' IDENTIFIED BY 'yourpasswordhere';
CREATE DATABASE erpnext;
GRANT ALL ON *.* TO 'erpnext'@'localhost' with grant option;
FLUSH PRIVILEGES;
QUIT;
Install curl
apt install curl
Setup erpnuser
useradd -m -s /bin/bash erpnuser
passwd erpnuser
usermod -aG sudo erpnuser
Setup environment
su - erpnuser
export LC_ALL=C.UTF-8
vim ~/.bashrc
PATH=$PATH:~/.local/bin/
Install Node using nvm
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
After nvm is installed, you may have to close your terminal and open another one.
exit
su - erpnuser
Now run the following command to install node.
nvm install 14
Verify the installation, by running:
node -v
# output
v14.19.3
Install yarn using npm
npm install -g yarn
Note about using pip (recommend use within venv)
WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip.
Please see https://github.com/pypa/pip/issues/5599 for advice on fixing the underlying issue.
To avoid this problem you can invoke Python with '-m pip' instead of running pip directly.
pip 22.1.2 from /usr/local/lib/python3.7/dist-packages/pip (python 3.7)
so instead run:
python3 -m pip --version
pip 22.1.2 from /usr/local/lib/python3.7/dist-packages/pip (python 3.7)
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venvf
Example (don't follow this literally, this is just a general guideline):
create the project directory and switch to it:
mkdir ~/my_app && cd ~/my_app
Copy
From inside the project root run the following command to create a virtual environment named my_app_venv:
python3.8 -m venv my_app_venv
Copy
Activate the environment:
source my_app_venv/bin/activate
Further System prep before ERPNext install
Enable redis automatically on startup (unless setting up DEV environment):
systemctl enable --now redis-server.service
as erpnuser:
pip3.8 install ansible
Double-check that yarn is installed via npm and not otherwise, else may cause problems.
As erpnuser:
npm install -g yarn
Setup erpnext install directory structure
Create a directory for ERPNext setup and provide erpnext
User read and write permissions on the directory:
sudo mkdir /srv/bench
sudo mkdir /srv/venv_erpnext
sudo chown -R erpnuser /srv/bench
sudo chown -R erpnuser /srv/venv_erpnext
su - erpnuser
cd /srv/bench
OR
cd /srv/venv_erpnext
python3.8 -m venv venv_erpnext
Install Bench
Install Bench CLI
pip3.8 install frappe-bench
Confirm the bench installation by checking version
bench --version
5.8.1
su - erpnuser
cd /srv/venv_erpnext
source venv_erpnext/bin/activate
Prompt should now look like this:
(venv_erpnext) erpnuser@erpnext1-deb10-stg-hh-rpgr:/srv/venv_erpnext$
Make sure pip is up to date
/usr/local/bin/python3.8 -m pip install --upgrade pip
OR
sudo -H /usr/local/bin/python3.8 -m pip install --upgrade pip
Which is better? because latter shows following warning:
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
cd /srv
/srv/venv_erpnext/venv_erpnext/bin/python3.8 -m pip install --upgrade pip
pip3.8 install frappe-bench
OR
sudo -H pip3 install frappe-bench
(but warnings about running as root and permission issues, so what is the correct approach?)
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
Why don't any of the erpnext instructions including venv approach?
THIS IS BEST OPTION (yes?):
(venv_erpnext) erpnuser@erpnext1-deb10-stg-hh-rpgr:/srv/venv_erpnext$ pip3.8 install frappe-bench
- To install the standard (Developer) branch:
-
$ bench init frappe-bench
-
OR
- To install the stable (version-13) branch:
-
$ bench init --frappe-branch version-13 frappe-bench
-
THIS IS BEST (yes?):
(venv_erpnext) erpnuser@erpnext1-deb10-stg-hh-rpgr:/srv/venv_erpnext$ bench init --frappe-branch version-13 frappe-bench
- Switch to the newly created Bench instance folder, the name you chose at point 1 above will be the name of the bench folder:
-
(venv_erpnext) erpnuser@erpnext1-deb10-stg-hh-rpgr:/srv/venv_erpnext$ cd frappe-bench/
-
test whether it installed correctly with the following command, which should return the currently installed Bench version, 5.3.0 at the time of updating this how-to:
-
(venv_erpnext) erpnuser@erpnext1-deb10-stg-hh-rpgr:/srv/venv_erpnext/frappe-bench$ bench --version
5.8.1
Download the ERPNExt app for Bench
- If you chose to go with the standard (Developer) branch during step 5:
-
(venv_erpnext) erpnuser@erpnext1-deb10-stg-hh-rpgr:/srv/venv_erpnext/frappe-bench$ bench get-app erpnext
-
- If you chose to go with the stable (version-13) branch during step 5:
-
(venv_erpnext) erpnuser@erpnext1-deb10-stg-hh-rpgr:/srv/venv_erpnext/frappe-bench$ bench get-app --branch version-13 erpnext
-
Create a site which will host your ERPNext instance:
- Note that you should use the fqdn (Fully Qualified Domain Name) which you set up in DNS. For this example we will use stg.rpgresearch.com. The MariaDB User you created at point 2 in Step 2 can be substituted if you did not use bench as the username for your instance.
- Create the Bench site:
(venv_erpnext) erpnuser@erpnext1-deb10-stg-hh-rpgr:/srv/venv_erpnext/frappe-bench$ bench new-site stg.rpgresearch.com --your-mariadb-root-username erpnext
- Provide the MariaDB password which you configured at point 2 in Step 2 here. For example "erpnext"
- During the installation, the installer will ask you to create an Administrator Password, make a note of the password you choose as you will need it to log in to ERPNext once it is installed.. Note I tried getting this to work with the mysql GRANT erpnext.* but it wouldn't install until I went with more risky *.* instead.
You can now manually start Bench using the command bench start, however we won't be doing that as we want it to start automatically, which is done by setting up Bench for Production Use.
Set up Bench for production use
- In order to use your ERPNext installation in a production environment, you should automate starting, maintenance and various other tasks, luckily Bench can do this for you by making use of Supervisor, which we installed during Step 1:
-
(venv_erpnext) erpnuser@erpnext1-deb10-stg-hh-rpgr:/srv/venv_erpnext/frappe-bench$ sudo bench setup production erpnext
[sudo] password for erpnuser: - Answer with (y) when asked to replace the default Supervisor and NginX config files.
-
THIS FAILS WITH DNS_MULTITENANT ON
Enable multi-tenancy for Bench:
(venv_erpnext) erpnuser@erpnext1-deb10-stg-hh-rpgr:/srv/venv_erpnext/frappe-bench$ bench config dns_multitenant on
ERROR "getpwnam" name not found: erpnext "erpnext"
Workaround, set dns_multitenant off
If multitenant already on, turn it off with: bench config dns_multitenant off
Otherwise just do the previous command earlier but with dns_multitenant off:
(venv_erpnext) erpnuser@erpnext1-deb10-stg-hh-rpgr:/srv/venv_erpnext/frappe-bench$ bench config dns_multitenant off
- Enable Bench scheduler:
-
(venv_erpnext) erpnuser@erpnext1-deb10-stg-hh-rpgr:/srv/venv_erpnext/frappe-bench$ bench enable-scheduler
-
Should now be finished.
Now simply point web browser at the site configured: http://stg.rpgresearch.com and it should show you the login page. Use Administrator as the username and the password which you configured during earlier.
Bench Command Not Found When Running Bench Setup Production
If sudo breaks the bench command - You'll need to install bench as sudo
(venv_erpnext) erpnuser@ip-172-31-15-101:/srv/venv_erpnext/frappe-bench$ sudo bench setup production erpnext
sudo: bench: command not found
(venv_erpnext) erpnuser@ip-172-31-15-101:/srv/venv_erpnext/frappe-bench$ sudo pip3.10 install frappe-bench
No domains available - drop-site and try again
(venv_erpnext) erpnuser@erpnext1-deb10-stg-hh-rpgr:/srv/venv_erpnext/frappe-bench$ bench drop-site stg.rpgresearch.com --db-root-username erpnext
(venv_erpnext) erpnuser@erpnext1-deb10-stg-hh-rpgr:/srv/venv_erpnext/frappe-bench$ bench new-site stg.rpgresearch.com --mariadb-root-username erpnext
(venv_erpnext) erpnuser@erpnext1-deb10-stg-hh-rpgr:/srv/venv_erpnext/frappe-bench$ bench get-app erpnext
A directory for the application 'erpnext' already exists. Do you want to continue and overwrite it? [y/N]: y
(venv_erpnext) erpnuser@erpnext1-deb10-stg-hh-rpgr:/srv/venv_erpnext/frappe-bench$ bench --site stg.rpgresearch.com install-app erpnext
That failed to work, so removing erpnext app from apps/erpnext:
bench remove erpnext
bench get-app erpnext
Installing erpnext
$ /srv/venv_erpnext/frappe-bench/env/bin/python -m pip install --quiet --upgrade -e /srv/venv_erpnext/frappe-bench/apps/erpnext
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
frappe 13.31.0 requires PyJWT~=1.7.1, but you have pyjwt 2.4.0 which is incompatible.
frappe 13.31.0 requires six~=1.15.0, but you have six 1.16.0 which is incompatible
pip install PyJWT==1.7.1
pip install six==1.15.0
bench remove erpnext
bench new-site stg.rpgresearch.com --mariadb-root-username erpnext
bench get-app erpnext
bench --site stg.rpgresearch.com install-app erpnext
errors, so drop site again
bench drop-site stg.rpgresearch.com --force --db-root-username erpnext
Trying this:
pip3 install frappe-bench
bench init --frappe-branch version-13 frappe-bench
cd frappe-bench
bench new-site stg.rpgresearch.com --mariadb-root-username erpnext
bench get-app --branch version-13 erpnext
bench --site stg.rpgresearch.com install-app erpnext
sudo bench setup production erpnuser
Now, due to recent problems it is important to check for the existence of an important configuration file. Execute the following command:
sudo ls /etc/supervisor/conf.d
If supervisor.conf is listed as a file here, then you can skip to the ‘enable scheduler’ step below. However, If there are no files listed then the supervisor.conf file was not transferred properly. To fix this perform the following command:
sudo cp /srv/venv_erpnext/frappe-bench/config/supervisor.conf /etc/supervisor/conf.d/supervisor.conf
This should fix the problem of not being able to get to the login screen. You can now finish the rest of the install.
bench --site stg.rpgresearch.com enable-scheduler
Now reboot the server. Once it has rebooted you should be able to open a web browser and type in the ip address of your server to get the ERPNext login screen
References
https://frappeframework.com/docs/v13/user/en/installation#debian-ubuntu
https://discuss.erpnext.com/t/successfully-install-erpnext-v13-beta7-on-debian-10-using-easy-install-script/69438/4
https://linuxize.com/post/how-to-install-python-3-8-on-debian-10/
https://computingforgeeks.com/how-to-install-pip-2-pip-3-on-debian/
https://codepre.com/install-erpnext-erp-system-on-debian-10-buster.html
https://buff0k.hrcity.co.za/2021/01/10/installing-erpnext-on-debian-10/
https://linuxize.com/post/how-to-install-python-3-8-on-debian-10/
https://codepre.com/install-erpnext-erp-system-on-debian-10-buster.html
https://discuss.erpnext.com/t/tutorial-how-to-manually-install-erpnext-v13-11-production-on-debian-10-w-ssl-cert/81017