Erpnext installation stuck in Ubuntu 22.04 LTS

I’m trying to install Erpnext on a VPS running Ubuntu 22.04 and I been running into a plethora of issues. I am using d-CodE’s installation tutorial to install Erpnext and it was running fine in development mode but I couldn’t get it to run in production mode. Eventually I got it to work in production mode but I ended up breaking the UI:

So I had reinstall my VPS and start from scratch again and now whenever I run bench get-app erpnext --branch version-13 or bench get-app https://github.com/frappe/erpnext --branch version-13 it gets stuck everytime at:

Installing erpnext
$ /home/ubuntu/frappe-bench/env/bin/python -m pip install --quiet --upgrade -e /home/ubuntu/frappe-bench/apps/erpnext

Here are the steps I have been following:

2. Install GIT

sudo apt-get install git

3. Install pythonc api

sudo apt-get install python3-dev

4. Install PIP and Setuptools for python

sudo apt-get install python3-setuptools python3-pip

5. Install virtual environment for python

sudo apt-get install virtualenv

6. Install MariaDB

sudo apt-get install software-properties-common
sudo apt install mariadb-server

7. Setup MariaDB’s root password and other settings

sudo mysql_secure_installation
$ Enter current password for root (enter for none): press enter here
$ Switch to unix_socket authentication [Y/n] n
$ Change the root password? [Y/n] y
$ New password: *enter your password here*
$ Re-enter new password: *enter your password here again*
$ Remove anonymous users? [Y/n] y
$ Disallow root login remotely? [Y/n] n
$ Remove test database and access to it? [Y/n] y
$ Reload privilege tables now? [Y/n] y

8. Install MYSQL C development library

sudo apt-get install libmysqlclient-dev

9. Edit MariaDB’s configuration file using nano (or vi whatever text editor you are comfortable with)

sudo nano /etc/mysql/mariadb.conf.d/50-server.cnf

Add the following to the file:

[server]
user = mysql
pid-file = /run/mysqld/mysqld.pid
socket = /run/mysqld/mysqld.sock
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
lc-messages-dir = /usr/share/mysql
bind-address = 127.0.0.1
query_cache_size = 16M
log_error = /var/log/mysql/error.log

[mysqld]
innodb-file-format=barracuda
innodb-file-per-table=1
innodb-large-prefix=1
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci

[mysql]
default-character-set = utf8mb4

Now these find these lines in the file, it should be under # * Character sets and comment them out using # :

# character-set-server  = utf8mb4
# collation-server      = utf8mb4_general_ci

Press Ctrl+S to save the edited file and Ctrl+X to exit.

Now restart MYSQL again:

sudo service mysql restart

10. Install Redis server

sudo apt-get install redis-server

11. Install Node.js 14.X

sudo apt install curl
curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash 
source ~/.profile
nvm install 14.15.0

12. Install NPM and Yarn (package managers)

sudo apt-get install npm
sudo npm install -g yarn

13. Install wkhtmltopdf

sudo apt-get install xvfb libfontconfig wkhtmltopdf

14. Install Bench

sudo -H pip3 install frappe-bench
bench --version

15. Initialize Bench

bench init frappe-bench 

16. Create your site for Bench and set it as the default site for Bench

cd frappe-bench/
bench new-site erp.mysite.com
bench use erp.mysite.com

17. Install Erpnext your Bench site

bench get-app erpnext --branch version-13

Or

bench get-app https://github.com/frappe/erpnext --branch version-13
bench --site erp.mysite.com install-app erpnext

18. Migrate your site and start Bench

bench migrate
bench start

If you are using a VPS, paste your server’s IP in the browser which should roughly look like xxx.xx.xx.xxx and the site should load up normally.

Now you can log into the site by using the following credentials:

Administrator
*password_you_created_during_setup*

I am absolutely end of my wits here.

3 Likes

Ok so this was solved by removing the branch version from bench get-app erpnext

Hi, the solution you mentioned did it fixed the UI after production mode setup??
i am also facing the same issue till development its working fine
as soon as i make sudo bench setup production… the UI Breaks…!!

Hi Guys.

I am also facing the same issue, Once i setup the production, All the CSS and JS are not found.

But if i invoke bench start, All the assets are retrieved properly and I can access via that 8000 port.

What is the mistake i am doing?

Thanks for the help.

@salim try bench setup requirements or bench update then bench migrate

@Bhushan

Tried… but still the same.

I was also looking at nginx error log, its says

[crit] 148550#148550: *1345 open() "/home/erpnext/frappe-bench/sites/assets/erpnext/dist/js/erpnext-web.bundle.SJSJGLAQ.js" failed (13: Permission denied)
[crit] 148550#148550: *1346 open() "/home/erpnext/frappe-bench/sites/assets/erpnext/images/erpnext-favicon.svg" failed (13: Permission denied)

Any idea how nginx user can access this file?, What permission should i have to set.

Did also a clean install on Ubuntu Server 22.04 / frappe & erpnext --branch version-14-beta and although did not encounter big problems, I did also have two hops:

  1. Installing erpnext now needs also the “payments” module, to solve that you have to install that manually or:
# bench get-app erpnext --branch version-14-beta --resolve-deps
  1. The “permissions error” was fixed with:
# sudo chmod 755 /home/${USER}

*logged in as the user where frappe-bench is installed

EDIT:
For the second point " chmod 751 " would suffice

3 Likes

@SobiDE Thank you so much.

This is fixed my issue.

Just to add to this. I think the reason for this error is this:

Getting Error - Could not find app “payments”

After the running below command

bench --site erpo.com install-app erpnext
Could not find app "payments"

@deepak_kulshrestha

After Frappe install
Before ERPNext install you
Must install payments and then ERPNext
as far as I understand.

Hope it helps!

how to install payments?
any command?

Thanks in advance

1 Like

SOLVED :white_check_mark:

Thanks

In my response was the simpler answer to your question:

# bench get-app --branch version-14 --resolve-deps erpnext
Following apps will be installed
1. payments (required by erpnext)
2. erpnext
....
1 Like

Hello

I have Followed your steps on ubuntu 22 and I got the below error when I run Above command

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/bench/commands/make.py", line 68, in init
    init(
  File "/usr/local/lib/python3.10/dist-packages/bench/utils/render.py", line 105, in wrapper_fn
    return fn(*args, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/bench/utils/system.py", line 63, in init
    bench.setup.dirs()
  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 329, in dirs
    os.makedirs(self.bench.name, exist_ok=True)
  File "/usr/lib/python3.10/os.py", line 225, in makedirs
    mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: 'frappe-bench'

ERROR: There was a problem while creating frappe-bench

Any Help please

Thank you in advance

Use this Command

cd frappe-bench/

chmod -R o+rx /home/[frappe-user]/

One alternative is to just add the www-data user (used by nginx) to the relevant user’s group (e.g. frappe). This can be done like so:

usermod -aG [frappe-user-group-name] www-data

While setting chmod 755 will give read + execute access to everyone, the above approach will only give access to the requisite www-data user.

EDIT: some other posts suggest adding your frappe user to the www-data group and changing ownership of your bench directory to be of the www-data group instead. Eventually, the benefit of doing so is that while the permissions being given are the same (read + execute), they are only given for the frappe-bench directory as opposed to the entire user directory (if you add www-data user to the the frappe user’s group)

TLDR: lesser perms are better; they help reduce potentially affected resources (if nginx gets hacked for example)

1 Like