inspired by the work of @abrefael, I have created a script that installs ERPNext production with almost no interaction. It also includes the option to SSL from Letsencrypt.
Just supply your database password, site name and site administrator password when required and the script will handle the rest.
The script is currently compatible with Ubuntu 22.04 only for now but I am working on adding compatibility for Debian.
I intend maintaining it long term and I welcome contributions to make the script better.
UPDATE: Support added for Ubuntu 20.04 LTS and Debian 10 (Buster). Partial support for Debian 11 (Bulls Eye). SSL Certificate issuance is currently failing on Debian 11 due to lib.X509_V_FLAG_CB_ISSUER_CHECK error. I am currently working to fix that error and once done an update will be deployed.
I also added error handler to stop the script at any point if an error is encountered. I will continue to improve the script as I develop it.
@Lei_Huang Thanks for the catch. Iβve removed reference to the file. I had set up a temp .my.cnf file to hold the mysql password during install but decided to hold it in a variable instead as it is more secure than saving the file in plain text while the script is running.
UPDATE: Full support for Debian 11 (Bulls Eye) has now been achieved. However, I am finding it difficult adding CentOS to the mix as I canβt seem to get bench production command to run on CentOS. If anyone has a working manual production install process for CentOS please share so I can adapt it to the auto install process.
It appears CentOS is no longer supported as Production environment setup fails on CentOS and even official documentation states only Debian/Ubuntu and MacOS are officially supported. So at this point I am giving up trying to add support for CentOS as it just wonβt work.
If anyone is able to find a way to install on CentOS I would very much appreciate such a walkthrough.
@CA_B.C_Chechani Thanks for the feedback. Can you assist with any information that will enable me troubleshoot? For instance, what Distro and OS version did you run on and was there any error displayed? if yeas, please share the error so I can use it to troubleshoot.
I managed the issue encountered, and itβs running. I will instruct someone in my team to try so we understand what the case was. Thanks. Your script is very useful. But as someone suggested already if we can have multiple parts and call one by one at different stages may be useful.
@CA_B.C_Chechani Thanks for the feedback. Indeed I am looking at the best way to break the script into multiple parts but the original intention was to make the script as an unattended ERPNext installer. However, I am working on satisfying both requests. I will release an update that will satisfy both intentions real soon.
Collecting google-auth~=1.29.0 (from frappe==14.38.0)
Downloading google_auth-1.29.0-py2.py3-none-any.whl (142 kB)
ββββββββββββββββββββββββββββββββββββββββ 142.9/142.9 kB 32.3 MB/s eta 0:00:00
Collecting posthog~=3.0.1 (from frappe==14.38.0)
Downloading posthog-3.0.1-py2.py3-none-any.whl (37 kB)
INFO: pip is looking at multiple versions of frappe to determine which version is compatible with other requirements. This could take a while.
ERROR: Package 'frappe' requires a different Python: 3.8.10 not in '>=3.10'
subprocess.CalledProcessError: Command '/root/frappe-bench/env/bin/python -m pip install --upgrade -e /root/frappe-bench/apps/frappe ' returned non-zero exit status 1.
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.8/dist-packages/bench/commands/make.py", line 68, in init
init(
File "/usr/local/lib/python3.8/dist-packages/bench/utils/render.py", line 105, in wrapper_fn
return fn(*args, **kwargs)
File "/usr/local/lib/python3.8/dist-packages/bench/utils/system.py", line 79, in init
get_app(
File "/usr/local/lib/python3.8/dist-packages/bench/app.py", line 444, in get_app
app.install(verbose=verbose, skip_assets=skip_assets, restart_bench=restart_bench)
File "/usr/local/lib/python3.8/dist-packages/bench/utils/render.py", line 126, in wrapper_fn
return fn(*args, **kwargs)
File "/usr/local/lib/python3.8/dist-packages/bench/app.py", line 242, in install
install_app(
File "/usr/local/lib/python3.8/dist-packages/bench/app.py", line 573, in install_app
bench.run(
File "/usr/local/lib/python3.8/dist-packages/bench/bench.py", line 48, in run
return exec_cmd(cmd, cwd=cwd or self.cwd, _raise=_raise)
File "/usr/local/lib/python3.8/dist-packages/bench/utils/__init__.py", line 158, in exec_cmd
raise CommandFailedError from subprocess.CalledProcessError(return_code, cmd)
bench.exceptions.CommandFailedError
ERROR: There was a problem while creating frappe-bench
Do you want to rollback these changes? [y/N]:
Setting Up supervisor...
ERROR: [Errno 2] No such file or directory: './config/supervisor.conf'
Traceback (most recent call last):
File "/usr/local/bin/bench", line 8, in <module>
sys.exit(cli())
File "/usr/local/lib/python3.8/dist-packages/bench/cli.py", line 127, in cli
bench_command()
File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 1130, in __call__
return self.main(*args, **kwargs)
File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 1055, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 1657, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 1657, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 760, in invoke
return __callback(*args, **kwargs)
File "/usr/local/lib/python3.8/dist-packages/bench/commands/setup.py", line 108, in setup_production
setup_production(user=user, yes=yes)
File "/usr/local/lib/python3.8/dist-packages/bench/config/production_setup.py", line 52, in setup_production
generate_supervisor_config(bench_path=bench_path, user=user, yes=yes)
File "/usr/local/lib/python3.8/dist-packages/bench/config/supervisor.py", line 72, in generate_supervisor_config
with open(conf_path, "w") as f:
FileNotFoundError: [Errno 2] No such file or directory: './config/supervisor.conf'
Setting Up prerequisites...
Setting Up supervisor...
From the error log it appears Python3.10 upgrade was not successful as indicated here:
INFO: pip is looking at multiple versions of frappe to determine which version is compatible with other requirements. This could take a while.
ERROR: Package 'frappe' requires a different Python: 3.8.10 not in '>=3.10'
subprocess.CalledProcessError: Command '/root/frappe-bench/env/bin/python -m pip install --upgrade -e /root/frappe-bench/apps/frappe ' returned non-zero exit status 1.
You can remove the frappe-bench directory, re-run the script and watch for python3.10 prompt:
It appears this instance does not meet the minimum Python version required for ERPNext 14 (Python3.10)β¦
And if the installation was successful, you will see this prompt:
Python3.10 installation successful!
This will confirm that Python3.10 was installed successfully.
You can also run python3.10 --version to check if it was installed successfully.
@Suresh_Thakor If youβre setting up a cloud VPS then youβre better off using Ubuntu 22.04 directly as it comes with Python3.10 by default. If youβre setting up in a local environment then download Ubuntu 22.04 instead of upgrading as upgrading the OS version may not include an upgrade to the python version. although the script is designed to assist with upgrading to python3.10 if not available and this has been tested extensively on all supported Distros so something else may have prevented the upgrade during your installation run.