Install v13 Production on Ubuntu 20.04 VPS - This is how I did it "Easy Install" script

Okay,

I promised I would post the steps I used to get this done and here they are:

**On Edit: found a typo in the commands for installing the prerequisites before running install.py. Corrected in this post now. 4/19/2021 :nerd_face:

**EDIT Again: improved/changed the steps to add the pre-install of redis server in order to also solve a problem with the redis.conf file that causes ERPNExt install failures on some Ubuntu 20.04 images. Not all images are affected this way but these extra steps prevent the problem anyway. Corrected in this post now. 5/25/2021 :nerd_face:

***Final EDIT: Please be aware the best practice for the past several weeks has been to abandon this “Easy Install” approach (even more so with Ubuntu 20.04). There are other threads on this forum now discussing the abandonment of the Easy Install Method across ALL operating systems, in favor of using either a “Manual Method” of install or using a Docker image. I have also previously written a method of manually installing on Ubuntu 20.04 and you can find it listed in great detail HERE at this LINK!! I would recommend the manual method over using the easy install method detailed below. I will NOT delete this older tutorial in the event portions of it can be useful in the future, but I no longer recommend this Easy Install method. EDIT 08/27/2021


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 [USER]
usermod -aG sudo [USER]

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 nano /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

The above method is mostly taken from @martin42 and tweaked to work best for me on RackNerd VPS servers here in the US. The install worked flawlessly with no errors and I have done it now 3 times on 3 different servers in 3 different cities. Very pleased with the result.

One caution…

Do NOT get impatient. Once you hit the return key after starting the install.py script the process took just over 2 hours on my small servers (3vCPU, 3.5gbRAM, 60GBssd)

The result was the same on all 3 identical servers in 3 different cities. There was not more than 10 minutes difference between the install times across all of them.

As Always… Your Milage May Vary! :sunglasses:

Hope this helps someone else.

BKM

17 Likes

Hello,
I want to upgrade erpnext 12 to 13 in ubuntu 20.04.would you please tell me

adduser [USER]
usermod -aG sudo [USER]
apt-get update
apt-get upgrade
export LC_ALL=C.UTF-8

sudo apt install git libffi-dev python-pip python3-minimal build-essential python3-distutils pythion3-setuptools libssl-dev wkhtmltopdf

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

are there any extra steps please advise…

Thanks
Ehasun

2 Likes

Sorry @ehasun.

The process I outlined above is NOT for upgrading from one version to another. It is ONLY for installing a new system. The upgrade process is available from other users on the forum if you search for: “Upgrade to v13” Use the magnifying glass icon in the upper right corner of the screen.

~BKM

Thanks @bkm .
Would you please tell me Ubuntu 20.04.2 LTS is ok to install erpnext 13 according to your steps ?

Thanks
Ehasun

Yes, it is.

~BKM

Hello. I confirm that even in WSL2 it is possible install successfully erpnet, if one install before systemd.

I’ve followed this link:
GitHub - DamionGans/ubuntu-wsl2-systemd-script: [Does not work anymore!] Script to enable systemd support on current Ubuntu WSL2 images

and followed after your guide. Take care at some typo in the istructions…

1 Like

Use Caution with WSL2 scripts. While it may work today, there is no warranty that it will work tomorrow or any other day in the future. Those scripts are essentially abandonware. Someone followed the old notes of someone else and created them as a one shot test environment.

Changes in the Ubuntu OS could make them useless at some point in the future. There is nothing in the git repos to indicate they will be supported any further than their initial creation.

BKM

you right. But actually I didn’t found any better for that. I hope that in future Wls2 patches this problem (not only for erpnext) will be resolved.

Welcome aboard @Ido_Traini

I should have noticed first that you are new to our forum. Very happy to see new members willing to share their experiences.

~BKM

python3-pip
python-pip not available in the repo anymore.

1 Like

I fallow all the steps.
But the last command ( sudo python3 install.py --verbose --production --user [USER] --mariadb-version 10.5 --frappe-branch version-13 --erpnext-branch version-13 ), It show error :
python3: can’t open file ‘install.py’: [Errno 2] No such file or directory

I have only seen that if you skip the line after the:

apt-get update
apt-get upgrade

The line I am talking about reads:

If you missed that line then you will run into trouble because the installer does not like to work from the root login.

However, I must also add that there are currently problems with the easy install script and it is failing in strange ways. I already have another thread on the forum about this, but there is no resolution yet.

~BKM

Understood, Thank you

@bkm

Perfect guide! Kudos!!!
Just a small edit:

sudo apt install python-pip

gives no installation candidate error.
It works with

sudo apt install python3-pip

Hope it helps :slight_smile:

Ok. Edited & Fixed in the steps at the top of this thread. Thank you for the reminder.

BKM

I just tried the install as described, but I run into the same issue that I experienced during the manual install:

[Errno 2] No such file or directory: '/home/erpnext/frappe-bench/env/bin/python

Any idea what goes wrong during the “bench init” run?

Here the output from your script:

TASK [bench : python3 bench init for production] *******************************
task path: /tmp/.bench/bench/playbooks/roles/bench/tasks/main.yml:44
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: root
<127.0.0.1> EXEC /bin/sh -c ‘echo ~root && sleep 0’
<127.0.0.1> EXEC /bin/sh -c ‘( umask 77 && mkdir -p “echo /var/tmp”&& mkdir /var/tmp/ansible-tmp-1622244757.3018384-10500-141330877233945 && echo ansible-tmp-1622244757.3018384-10500-141330877233945=“echo /var/tmp/ansible-tmp-1622244757.3018384-10500-141330877233945” ) && sleep 0’
Using module file /usr/local/lib/python3.8/dist-packages/ansible/modules/commands/command.py
<127.0.0.1> PUT /root/.ansible/tmp/ansible-local-5474dabc0upr/tmp70mre4hw TO /var/tmp/ansible-tmp-1622244757.3018384-10500-141330877233945/AnsiballZ_command.py
<127.0.0.1> EXEC /bin/sh -c ‘setfacl -m u:erpnext:r-x /var/tmp/ansible-tmp-1622244757.3018384-10500-141330877233945/ /var/tmp/ansible-tmp-1622244757.3018384-10500-141330877233945/AnsiballZ_command.py && sleep 0’
<127.0.0.1> EXEC /bin/sh -c ‘sudo -H -S -n -u erpnext /bin/sh -c ‘"’“‘echo BECOME-SUCCESS-updudkfkwxrohrwjzlblojsyencnepdc ; /usr/bin/python3 /var/tmp/ansible-tmp-1622244757.3018384-10500-141330877233945/AnsiballZ_command.py’”’"’ && sleep 0’
<127.0.0.1> EXEC /bin/sh -c ‘rm -f -r /var/tmp/ansible-tmp-1622244757.3018384-10500-141330877233945/ > /dev/null 2>&1 && sleep 0’
fatal: [localhost]: FAILED! => {
“changed”: true,
“cmd”: [
“bench”,
“init”,
“/home/erpnext/frappe-bench”,
“–frappe-path”,
GitHub - frappe/frappe: Low code web framework for real world applications, in Python and Javascript”,
“–frappe-branch”,
“version-13”,
“–python”,
“python3”
],
“delta”: “0:00:05.564139”,
“end”: “2021-05-28 23:32:43.045758”,
“invocation”: {
“module_args”: {
“_raw_params”: “bench init /home/erpnext/frappe-bench --frappe-path GitHub - frappe/frappe: Low code web framework for real world applications, in Python and Javascript --frappe-branch version-13 --python python3”,
“_uses_shell”: false,
“argv”: null,
“chdir”: null,
“creates”: “/home/erpnext/frappe-bench”,
“executable”: null,
“removes”: null,
“stdin”: null,
“stdin_add_newline”: true,
“strip_empty_ends”: true,
“warn”: true
}
},
“msg”: “non-zero return code”,
“rc”: 1,
“start”: “2021-05-28 23:32:37.481619”,
“stderr”: “Cloning into ‘frappe’…\nAborted!”,
“stderr_lines”: [
“Cloning into ‘frappe’…”,
“Aborted!”
],
“stdout”: "ModuleNotFoundError: No module named ‘virtualenv.seed.via_app_data’\n\u001b[93mWARN: bench is installed in editable mode!\n\nThis is not the recommended mode of installation for production. Instead, install the package from PyPI with: pip install frappe-bench\n\u001b[0m\n\u001b[90m$ /usr/local/bin/virtualenv -q env -p python3\u001b[0m\n\n\u001b[93mGetting frappe\u001b[0m\n\u001b[90m$ git clone GitHub - frappe/frappe: Low code web framework for real world applications, in Python and Javascript --branch version-13 --depth 1 --origin upstream\u001b[0m\n\n\u001b[93mInstalling frappe\u001b[0m\n\u001b[90m$ /home/erpnext/frappe-bench/env/bin/python -m pip install -q -U -e /home/erpnext/frappe-bench/apps/frappe \u001b[0m\n[Errno 2] No such file or directory: ‘/home/erpnext/frappe-bench/env/bin/python’\n\u001b[91mERROR: There was a problem while creating /home/erpnext/frappe-bench\u001b[0m\nDo you want to rollback these changes? [y/N]: ",
“stdout_lines”: [
“ModuleNotFoundError: No module named ‘virtualenv.seed.via_app_data’”,
“\u001b[93mWARN: bench is installed in editable mode!”,
“”,
“This is not the recommended mode of installation for production. Instead, install the package from PyPI with: pip install frappe-bench”,
“\u001b[0m”,
“\u001b[90m$ /usr/local/bin/virtualenv -q env -p python3\u001b[0m”,
“”,
“\u001b[93mGetting frappe\u001b[0m”,
“\u001b[90m$ git clone GitHub - frappe/frappe: Low code web framework for real world applications, in Python and Javascript --branch version-13 --depth 1 --origin upstream\u001b[0m”,
“”,
“\u001b[93mInstalling frappe\u001b[0m”,
“\u001b[90m$ /home/erpnext/frappe-bench/env/bin/python -m pip install -q -U -e /home/erpnext/frappe-bench/apps/frappe \u001b[0m”,
“[Errno 2] No such file or directory: ‘/home/erpnext/frappe-bench/env/bin/python’”,
“\u001b[91mERROR: There was a problem while creating /home/erpnext/frappe-bench\u001b[0m”,
"Do you want to rollback these changes? [y/N]: "
]
}

PLAY RECAP *********************************************************************
localhost : ok=67 changed=20 unreachable=0 failed=1 skipped=62 rescued=0 ignored=0

Traceback (most recent call last):
File “install.py”, line 500, in
install_bench(args)
File “install.py”, line 281, in install_bench
run_playbook(‘site.yml’, sudo=True, extra_vars=extra_vars)
File “install.py”, line 416, in run_playbook
success = subprocess.check_call(args, cwd=playbooks_folder, stdout=log_stream, stderr=sys.stderr)
File “/usr/lib/python3.8/subprocess.py”, line 364, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command ‘[‘ansible-playbook’, ‘-c’, ‘local’, ‘site.yml’, ‘-vvvv’, ‘-e’, ‘@/tmp/extra_vars.json’, ‘–become’, ‘–become-user=erpnext’]’ returned non-zero exit status 2.

@dkalisch The problem you are running into is caused by a a change in the redis.conf file.

All you have to do is edit the file as this post inticates:

After you get the failure you can edit the file like in the post and then re-run the install and it will work.

Hope that helps.

BKM

@bkm No, that was actually not the problem, I had the redis.conf set correctly to 127.0.0.1 only already. The problem was, that the virtualenv didn’t set up correctly.

I uninstalled everything python, redid etc. Then I started again according to the description here: https://github.com/frappe/frappe/wiki/The-Hitchhiker%27s-Guide-to-Installing-Frappe-on-Linux

It is manual, but at least I have more control over it now :slight_smile:

Then it would be helpful for you to add back to the post what exactly you found wrong with the virtualenv install and what fixed it so that others can also benefit from your revelation.

That is how the community grows here. Please post your specific fix and we can add it to the list of pre-requisites to get right before running the install.py (which is the topic of this thread).

Thanks in advance for your participation.

BKM

1 Like

@bkm I actually don’t think that something was wrong with the script, it probably was more something I did before. I am trying to install ERPNext on a machine that already existed and not a fresh one.