Steps to install ERPNext without bench

This is not for beginners. This is for people who wish to understand bench.

Following steps assume python 3, nodejs, yarn, mariadb, redis and other dependencies are manually installed

Setup directory structure

mkdir benchless && cd benchless
mkdir -p apps logs sites

Setup Python environment

python -m venv env
git clone https://github.com/frappe/frappe apps/frappe --depth 1 --branch develop
./env/bin/pip install --no-cache-dir -e apps/frappe
git clone https://github.com/frappe/erpnext apps/erpnext --depth 1 --branch develop
./env/bin/pip install --no-cache-dir -e apps/erpnext
echo -e "frappe\nerpnext" > sites/apps.txt

Setup NodeJs dependencies

yarn --cwd apps/frappe

Create bench_helper and make it executable

nano bench_helper

Add following lines to the file

#!/bin/sh

export script_dir="$(dirname "$0")"
cd $script_dir/sites
../env/bin/python ../apps/frappe/frappe/utils/bench_helper.py frappe "$@"

Make the file executable

chmod +x bench_helper

Use bench commands

./bench_helper --help

Build static assets

./bench_helper build

Add common_site_config.json for specifying hosts

nano sites/common_site_config.json

Add following lines

{
 "db_host": "0.0.0.0",
 "db_port": 3306,
 "redis_cache": "redis://localhost:13000",
 "redis_queue": "redis://localhost:11000",
 "redis_socketio": "redis://localhost:12000"
}

Start processes with honcho

# Install honcho
./env/bin/pip install honcho
# Edit Procfile
nano Procfile

Add following lines

redis_cache: redis-server --port 13000
redis_socketio: redis-server --port 12000
redis_queue: redis-server --port 11000

socketio: node apps/frappe/socketio.js

web: ./bench_helper serve --port 8000

watch: ./bench_helper watch

schedule: ./bench_helper schedule
worker_short: ./bench_helper worker --queue short
worker_long: ./bench_helper worker --queue long
worker_default: ./bench_helper worker --queue default

start processes

./env/bin/honcho start

Start mariadb

Apply frappe specific config for mariadb. e.g. frappe.cnf

sudo systemctl start mariadb.service

Create new site

./bench_helper new-site mysite.localhost --install-app erpnext

Drop site

./bench_helper drop-site mysite.localhost
12 Likes

Mind blowing.

This should be for “beginners” because no error happened…:smiley: :+1:
Should be extended to production :slight_smile:

Try this

1 Like

Awesome inside in what bench is actually doing.

Looking at the scripts, we must clone the repo to the benchless and run it from the start (setup-erpnext.sh).

If we follow up from the steps in this thread, we clone it and just run production.py, right?

Things are experimental.

Clone and follow readme.

Clone as any name, (e.g. bench-01, microbench01)

setup-erpnext.sh

Then,

./env/bin/python production

Then, symlink supervisor.conf and nginx.conf

I tested supervisor, it works.

Nginx, certbot not tested yet.

When things get automated, problems arise :smiley:
I have problem the script recognizing python location.
So I try the script 1 by 1 line. So far it’s done well.

And I think you assume the process is done by root?

Only the symlink is done by root.

Rest can be done by non root user.

Basically this is what bench does, just that bench has the code even to support v4 frappe and many other things like systemd setup that no one uses.

I ran it on machine where python 3 was in $PATH as python.

python -m venv env worked because of that.

I think there should be alias python=python3, can you try that?

yes that was I did. it pass now.

still problem is running ./bench_helper got this:

Traceback (most recent call last):
  File "../apps/frappe/frappe/utils/bench_helper.py", line 2, in <module>
    import click
ModuleNotFoundError: No module named 'click'

but I have click installed in /usr/local/lib/python3.6/site-packages

I just wrapped up the scripts for convenience.

bench_helper uses the env that is setup in the beginning.

It’s internally changing the working directory to sites and then executes this:

../env/bin/python ../apps/frappe/frappe/utils/bench_helper.py frappe "$@"

It doesn’t work. I have to change the python to python3 in the script then it works.
maybe i can try later to put the path in to $PATH.

Secondly,
I think in install_app.sh line 6 you have it wrong?

./env/bin/pip install --no-cache-dir -e $1
should be
./env/bin/pip install --no-cache-dir -e apps/$2

And you left this out chmod +x bench_helper.

On Debian/Ubuntu, apt install python-is-python3 will do the same so that python3 is default on your system.

using python3 in script now.

Fixed it.

No need. I made the file executable before commiting. git clone will fetch it as executable.

Haven’t tried this, just skimming for now, but – where’re mariadb passwords configured?

Not part of steps right now.

Oh, sorry. Yeah, that should be obvious, shouldn’t it. :roll_eyes:

Too many variables to have it in a simple script.

For mariadb:

  • distribution
  • make it use tcp instead of unix socket
  • frappe.cnf
  • managed service
  • separately hosted, private network server

Yup.

… and no two admins want the same thing. Whatever you do they’ll label it “opinionated”, and do something else.

@revant_one, Sir can you explain how to setup nginx, lets encrypt, gunicorn and supervisor manually without script because i want to know how bench work more deeply, this will be usefull if we want to install erpnext on every OS linux and BSD that not using systemd and installing pypy as python interpreter, thank you if you want to explain it to us