From 825a718a078229530ab700c82e0216b1acaeeb1a Mon Sep 17 00:00:00 2001 From: "CanbiZ (MickLesk)" <47820557+MickLesk@users.noreply.github.com> Date: Wed, 25 Mar 2026 14:26:04 +0100 Subject: [PATCH] fix(erpnext): run bench setup production as root, add nginx+supervisor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - bench setup production requires root (is_root check) - was failing as frappe user - Add nginx and supervisor as apt dependencies for production setup - Remove custom erpnext.service - bench manages gunicorn+workers via supervisor - Port 8000 → 80 (nginx reverse proxy) - Fix bench update in CT to run as frappe user with proper PATH --- ct/erpnext.sh | 5 ++--- install/erpnext-install.sh | 25 ++++--------------------- json/erpnext.json | 2 +- 3 files changed, 7 insertions(+), 25 deletions(-) diff --git a/ct/erpnext.sh b/ct/erpnext.sh index a20a7392..6ee8a4e8 100644 --- a/ct/erpnext.sh +++ b/ct/erpnext.sh @@ -31,8 +31,7 @@ function update_script() { fi msg_info "Updating ERPNext" - cd /opt/frappe-bench - $STD bench update --reset + $STD sudo -u frappe bash -c 'export PATH="$HOME/.local/bin:$PATH"; cd /opt/frappe-bench && bench update --reset' msg_ok "Updated ERPNext" exit } @@ -44,7 +43,7 @@ description msg_ok "Completed Successfully!\n" echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}" echo -e "${INFO}${YW} Access it using the following URL:${CL}" -echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:8000${CL}" +echo -e "${TAB}${GATEWAY}${BGN}http://${IP}${CL}" echo -e "${INFO}${YW} Credentials:${CL}" echo -e "${TAB}${BGN}Username: Administrator${CL}" echo -e "${TAB}${BGN}Password: see /opt/frappe-bench/.env${CL}" diff --git a/install/erpnext-install.sh b/install/erpnext-install.sh index ab1d05c7..8daf76c0 100644 --- a/install/erpnext-install.sh +++ b/install/erpnext-install.sh @@ -22,6 +22,8 @@ $STD apt install -y \ libffi-dev \ libssl-dev \ redis-server \ + nginx \ + supervisor \ xvfb \ libfontconfig1 \ libxrender1 \ @@ -79,29 +81,10 @@ $STD systemctl enable --now redis-server msg_ok "Configured ERPNext" msg_info "Setting up Production" -$STD sudo -u frappe bash -c 'export PATH="$HOME/.local/bin:$PATH"; cd /opt/frappe-bench && bench setup production frappe --yes' +$STD bash -c 'export PATH="/home/frappe/.local/bin:$PATH"; cd /opt/frappe-bench && bench setup production frappe --yes' +$STD systemctl enable --now supervisor msg_ok "Set up Production" -msg_info "Creating Service" -cat </etc/systemd/system/erpnext.service -[Unit] -Description=ERPNext (Frappe Bench) -After=network.target mariadb.service redis-server.service - -[Service] -Type=simple -User=frappe -WorkingDirectory=/opt/frappe-bench -ExecStart=/opt/frappe-bench/env/bin/gunicorn --bind 0.0.0.0:8000 --workers 4 --timeout 120 frappe.app:application -Restart=on-failure -RestartSec=5 - -[Install] -WantedBy=multi-user.target -EOF -systemctl enable -q --now erpnext -msg_ok "Created Service" - motd_ssh customize cleanup_lxc diff --git a/json/erpnext.json b/json/erpnext.json index dd3cdbee..0f8768da 100644 --- a/json/erpnext.json +++ b/json/erpnext.json @@ -8,7 +8,7 @@ "type": "ct", "updateable": true, "privileged": false, - "interface_port": 8000, + "interface_port": 80, "documentation": "https://docs.erpnext.com/", "website": "https://erpnext.com/", "logo": "https://cdn.jsdelivr.net/gh/selfhst/icons@main/webp/erpnext.webp",