[Guide] How to install ERPNext v15 on Linux Ubuntu (step-by-step instructions)

Hi,

best instructions so far, but I am facing an error on a plain Ubuntu 22.02. installation.

frappe@eprv15:~/frappe-bench$ bench restart
$ sudo supervisorctl restart frappe-bench-web:
frappe-bench-web:frappe-bench-frappe-web: stopped
frappe-bench-web:frappe-bench-node-socketio: ERROR (spawn error)
frappe-bench-web:frappe-bench-frappe-web: started
ERROR: sudo supervisorctl restart frappe-bench-web:
subprocess.CalledProcessError: Command 'sudo supervisorctl restart frappe-bench-web:' returned non-zero exit status 7.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/bin/bench", line 8, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.10/dist-packages/bench/cli.py", line 132, in cli
    bench_command()
  File "/usr/local/lib/python3.10/dist-packages/bench/commands/utils.py", line 41, in restart
    Bench(".").reload(web, supervisor, systemd)
  File "/usr/local/lib/python3.10/dist-packages/bench/utils/render.py", line 126, in wrapper_fn
    return fn(*args, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/bench/bench.py", line 152, in reload
    restart_supervisor_processes(bench_path=self.name, web_workers=web, _raise=_raise)
  File "/usr/local/lib/python3.10/dist-packages/bench/utils/bench.py", line 327, in restart_supervisor_processes
    failure = bench.run(f"{sudo}supervisorctl restart {group}", _raise=_raise)
  File "/usr/local/lib/python3.10/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.10/dist-packages/bench/utils/__init__.py", line 158, in exec_cmd
    raise CommandFailedError(cmd) from subprocess.CalledProcessError(return_code, cmd)
bench.exceptions.CommandFailedError: sudo supervisorctl restart frappe-bench-web:

frappe@eprv15:~/frappe-bench$ sudo supervisorctl status
frappe-bench-redis:frappe-bench-redis-cache               RUNNING   pid 11933, uptime 0:04:30
frappe-bench-redis:frappe-bench-redis-queue               RUNNING   pid 11934, uptime 0:04:30
frappe-bench-web:frappe-bench-frappe-web                  RUNNING   pid 12035, uptime 0:03:48
frappe-bench-web:frappe-bench-node-socketio               FATAL     Exited too quickly (process log may have details)
frappe-bench-workers:frappe-bench-frappe-long-worker-0    RUNNING   pid 11947, uptime 0:04:30
frappe-bench-workers:frappe-bench-frappe-schedule         RUNNING   pid 11937, uptime 0:04:30
frappe-bench-workers:frappe-bench-frappe-short-worker-0   RUNNING   pid 11946, uptime 0:04:30

node-socketio.error.log:

SyntaxError: Unexpected token '.'
    at wrapSafe (internal/modules/cjs/loader.js:915:16)
    at Module._compile (internal/modules/cjs/loader.js:963:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Module.require (internal/modules/cjs/loader.js:887:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (/home/frappe/frappe-bench/apps/frappe/node_modules/@redis/client/dist/index.js:18:18)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
/home/frappe/frappe-bench/apps/frappe/node_modules/@redis/client/dist/lib/client/index.js:35
            modules: extensions?.modules,
                                ^

supervisor.conf:

frappe@eprv15:~/frappe-bench/config$ cat supervisor.conf 
; Notes:
; priority=1 --> Lower priorities indicate programs that start first and shut down last
; killasgroup=true --> send kill signal to child processes too

; graceful timeout should always be lower than stopwaitsecs to avoid orphan gunicorn workers.
[program:frappe-bench-frappe-web]
command=/home/frappe/frappe-bench/env/bin/gunicorn -b 127.0.0.1:8000 -w 9 --max-requests 5000 --max-requests-jitter 500 -t 120 --graceful-timeout 30 frappe.app:application --preload
priority=4
autostart=true
autorestart=true
stdout_logfile=/home/frappe/frappe-bench/logs/web.log
stderr_logfile=/home/frappe/frappe-bench/logs/web.error.log
stopwaitsecs=40
killasgroup=true
user=frappe
directory=/home/frappe/frappe-bench/sites

[program:frappe-bench-frappe-schedule]
command=/usr/local/bin/bench schedule
priority=3
autostart=true
autorestart=true
stdout_logfile=/home/frappe/frappe-bench/logs/schedule.log
stderr_logfile=/home/frappe/frappe-bench/logs/schedule.error.log
user=frappe
directory=/home/frappe/frappe-bench



[program:frappe-bench-frappe-short-worker]
command=/usr/local/bin/bench worker --queue short,default
priority=4
autostart=true
autorestart=true
stdout_logfile=/home/frappe/frappe-bench/logs/worker.log
stderr_logfile=/home/frappe/frappe-bench/logs/worker.error.log
user=frappe
stopwaitsecs=360
directory=/home/frappe/frappe-bench
killasgroup=true
numprocs=1
process_name=%(program_name)s-%(process_num)d

[program:frappe-bench-frappe-long-worker]
command=/usr/local/bin/bench worker --queue long,default,short
priority=4
autostart=true
autorestart=true
stdout_logfile=/home/frappe/frappe-bench/logs/worker.log
stderr_logfile=/home/frappe/frappe-bench/logs/worker.error.log
user=frappe
stopwaitsecs=1560
directory=/home/frappe/frappe-bench
killasgroup=true
numprocs=1
process_name=%(program_name)s-%(process_num)d





[program:frappe-bench-redis-cache]
command=/usr/bin/redis-server /home/frappe/frappe-bench/config/redis_cache.conf
priority=1
autostart=true
autorestart=true
stdout_logfile=/home/frappe/frappe-bench/logs/redis-cache.log
stderr_logfile=/home/frappe/frappe-bench/logs/redis-cache.error.log
user=frappe
directory=/home/frappe/frappe-bench/sites

[program:frappe-bench-redis-queue]
command=/usr/bin/redis-server /home/frappe/frappe-bench/config/redis_queue.conf
priority=1
autostart=true
autorestart=true
stdout_logfile=/home/frappe/frappe-bench/logs/redis-queue.log
stderr_logfile=/home/frappe/frappe-bench/logs/redis-queue.error.log
user=frappe
directory=/home/frappe/frappe-bench/sites



[program:frappe-bench-node-socketio]
command=/usr/bin/node /home/frappe/frappe-bench/apps/frappe/socketio.js
priority=4
autostart=true
autorestart=true
stdout_logfile=/home/frappe/frappe-bench/logs/node-socketio.log
stderr_logfile=/home/frappe/frappe-bench/logs/node-socketio.error.log
user=frappe
directory=/home/frappe/frappe-bench


[group:frappe-bench-web]
programs=frappe-bench-frappe-web,frappe-bench-node-socketio




[group:frappe-bench-workers]
programs=frappe-bench-frappe-schedule,frappe-bench-frappe-short-worker,frappe-bench-frappe-long-worker




[group:frappe-bench-redis]
programs=frappe-bench-redis-cache,frappe-bench-redis-queue

bench --version: 5.20.0
node -v: v18.19.0

I am trying to get v15 up and running different way and servers/VMs, but everywhere the same error.
any ideas, how to fix this?

br
Andreas

me have same issue

/frappe-bench$ sudo supervisorctl restart all
frappe-bench-workers:frappe-bench-frappe-schedule: stopped
frappe-bench-redis:frappe-bench-redis-cache: stopped
frappe-bench-redis:frappe-bench-redis-queue: stopped
frappe-bench-workers:frappe-bench-frappe-short-worker-0: stopped
frappe-bench-workers:frappe-bench-frappe-long-worker-0: stopped
frappe-bench-web:frappe-bench-frappe-web: stopped
frappe-bench-web:frappe-bench-node-socketio: ERROR (spawn error)
frappe-bench-redis:frappe-bench-redis-cache: started
frappe-bench-redis:frappe-bench-redis-queue: started
frappe-bench-web:frappe-bench-frappe-web: started
frappe-bench-workers:frappe-bench-frappe-schedule: started
frappe-bench-workers:frappe-bench-frappe-short-worker-0: started
frappe-bench-workers:frappe-bench-frappe-long-worker-0: started

frappe-bench-web:frappe-bench-node-socketio: ERROR (spawn error)

killall -9 node will terminate the process, and then you can run
supervisorctl restart all

:~/frappe-bench$ killall -9 node
node: no process found

Can you do one for k8s using helm charts?

1 Like

This helped me:

$ bench doctor
$ bench update --requirements
$ bench setup socketio
$ bench setup redis
$ bench retry-upgrade
$ sudo supervisorctl restart
$ sudo service nginx restart>

br
Andreas

2 Likes

Hey everyone,

Made a simple install script with prompts and stuff…
Enjoy!

1 Like

On

bench new-site --verbose site1.local

I get the below error

Created user _b533f5fdd65aaf8c
Created database _b533f5fdd65aaf8c
Granted privileges to user _b533f5fdd65aaf8c and database _b533f5fdd65aaf8c
Starting database import...
Imported from database /home/frappe/frappe-bench/apps/frappe/frappe/database/mariadb/framework_mariadb.sql
Illegal instruction (core dumped)

I am installing on this on Ubuntu 22.04.4 LTS installed on Virtual Box 7.0 on windows host.

1 Like

If you are on Proxmox VM Ubuntu then you need to set for CPU that its using HOST so it passes AVX AVX2 instructions from CPU

Hi Dino_M

How can I change avx2 settings ? Can u help me ?

Change it to host under cpu configuration

how do i change it? I don’t use host. It’s a local computer at work.

today i tried this script and it has errors and the installation fails, it needs a revision

What OS version did you install on?

1 Like

ubuntu 22.04.4 LTS

for your information, today i also tried again, it starts well and until it says mariadb installed successfully is very well, but after that the terminal closes and fades away.

If you can say what errors you get, it can help debug it…
That been said,
I too am having some problems with the installation (be it with or without the script).
I am getting to the part of sudo bench setup production frappe and there is an error at bench setup role fail2ban:

ERROR! [DEPRECATED]: ansible.builtin.include has been removed. Use include_tasks or import_tasks instead. This feature was removed from ansible-core in a release after 2023-05-16. Please update your playbooks.

The error appears to be in '/usr/local/lib/python3.10/dist-packages/bench/playbooks/roles/mariadb/tasks/main.yml': line 2, column 3, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

---
- include: centos.yml
  ^ here
ERROR: Command '['ansible-playbook', '-c', 'local', 'site.yml', '-vvvv', '-e', '{"production": true, "admin_emails": "", "mysql_root_password": null, "container": false}', '-t', 'fail2ban']' returned non-zero exit status 1.
Traceback (most recent call last):
  File "/usr/local/bin/bench", line 8, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.10/dist-packages/bench/cli.py", line 132, in cli
    bench_command()
  File "/usr/lib/python3/dist-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3/dist-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python3/dist-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python3/dist-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3/dist-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/bench/commands/setup.py", line 370, in setup_roles
    run_playbook("site.yml", extra_vars=extra_vars, tag=role)
  File "/usr/local/lib/python3.10/dist-packages/bench/utils/__init__.py", line 345, in run_playbook
    subprocess.check_call(args, cwd=os.path.join(bench.__path__[0], "playbooks"))
  File "/usr/lib/python3.10/subprocess.py", line 369, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['ansible-playbook', '-c', 'local', 'site.yml', '-vvvv', '-e', '{"production": true, "admin_emails": "", "mysql_root_password": null, "container": false}', '-t', 'fail2ban']' returned non-zero exit status 1.
ERROR: bench setup role fail2ban
subprocess.CalledProcessError: Command 'bench setup role fail2ban' 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/bin/bench", line 8, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.10/dist-packages/bench/cli.py", line 132, in cli
    bench_command()
  File "/usr/local/lib/python3.10/dist-packages/bench/commands/setup.py", line 110, in setup_production
    setup_production(user=user, yes=yes)
  File "/usr/local/lib/python3.10/dist-packages/bench/config/production_setup.py", line 37, in setup_production
    setup_production_prerequisites()
  File "/usr/local/lib/python3.10/dist-packages/bench/config/production_setup.py", line 28, in setup_production_prerequisites
    exec_cmd("bench setup role fail2ban")
  File "/usr/local/lib/python3.10/dist-packages/bench/utils/__init__.py", line 178, in exec_cmd
    raise CommandFailedError(cmd) from subprocess.CalledProcessError(return_code, cmd)
bench.exceptions.CommandFailedError: bench setup role fail2ban

Any idea what’s going on?
The system is Ubuntu 22.04, installed from ubuntu 22.04.4 media.
Maybe there is a way to change the ansible version, or change the playbook according to the change in the ansible software?

I did fix it by manually changing: /usr/local/lib/python3.10/dist-packages/bench/playbooks/roles/mariadb/tasks/main.yml, so that the three includes in the begining of the file will be include_tasks as the error message states in the begining. This seemed to fix the issue…

https://medium.com/@prasantpant/update-your-frappe-to-specific-latest-version-a08689fcd296

https://medium.com/devops-dev/erpnext-for-production-via-linux-os-step-by-step-frappe-fa36d0ed061e

I have updated the script to handle the Ansible issue which breaks production setup due to the recent update. I’ve also added support for Ubuntu 23.04, 24.04 and Debian 12.

2 Likes

I am happy that you were able to find out a way, but the problem is i dont see any error message, the terminal closes automatically

Hmmm… :thinking:
Maybe try:

./erpNext15install.sh >> log.log

And see if the file has anything in it…

1 Like