Enterprise Production Setup & Security (ERPNext v16 / Ubuntu 25)

Frappe Production Setup Guide

Step 1: Stop Development Mode

Before setting up production, ensure you are not running the site manually. Go to your terminal where bench start is running and press Ctrl + C to stop it. Ensure no Python processes are holding the ports.

Step 2: System Preparation & Cleaning

Ubuntu often pre-installs Apache, which conflicts with Nginx on Port 80. We remove it to prevent “Address already in use” errors.

Bash

# Remove Apache to prevent conflicts
sudo systemctl disable --now apache2
sudo apt remove apache2 -y

# Install the runtime engines
sudo apt update -y && sudo apt upgrade -y
sudo apt install -y nginx supervisor redis-server fail2ban

Step 3: Configuration Generation

Run these commands as your bench user. We ask Frappe to generate the correct configuration files for your specific site.

Bash

# Create Nginx routing rules
bench setup nginx 

# Create Supervisor worker instructions
bench setup supervisor

Step 4: System Linking

We manually plug your generated files into the operating system using Symbolic Links.

Note: Replace /home/frappe_user in the commands below with your actual home directory path (e.g., /home/frappe_user).

Bash

# Link the Web Config (-sf forces overwrite of old links)
sudo ln -sf /home/frappe_user/frappe-bench/config/nginx.conf /etc/nginx/conf.d/frappe-bench.conf  

# Link the Worker Config
sudo ln -sf /home/frappe_user/frappe-bench/config/supervisor.conf /etc/supervisor/conf.d/frappe-bench.conf

Step 5: Nginx Log Format Fix (Ubuntu 25 Config)

Ubuntu’s default Nginx is missing the “main” log format Frappe expects.

  1. Edit the global config:

    Bash

    sudo nano /etc/nginx/nginx.conf
    
    
  2. Scroll to the http { block. Paste the following exactly once above the access_log line:

    Nginx

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';
    
    
  3. Save (Ctrl+O, Enter) and Exit (Ctrl+X).

  4. Test the syntax:

    Bash

    sudo nginx -t
    
    

    (Proceed only if it says “syntax is ok”)

Step 6: Permissions & Assets

If permissions are too tight, Nginx cannot read CSS/JS files.

Bash

# Allow Nginx to traverse your home folder
chmod o+x /home/frappe_user

# Compile Production Assets (CSS/JS)
cd ~/frappe-bench 
bench build

# Reset Ownership (Fixes Supervisor "Spawn Errors")
# Replace 'frappe_user:frappe_user' with your actual user:group
sudo chown -R frappe_user:frappe_user /home/frappe_user/frappe-bench

Step 7: Routing & Activation

We set the default site and remove the Nginx welcome page.

Bash

# Set your site as default (Replace with actual name)
bench use your_site_name

# DELETE DEFAULT NGINX PAGE
sudo rm /etc/nginx/sites-enabled/default 

# Regenerate Nginx config with new default
bench setup nginx 

# Reload Nginx
sudo service nginx reload 

# Restart Supervisor
sudo service supervisor restart
sudo supervisorctl reload

Step 8: Security (Firewall)

Configure UFW to secure your server while allowing essential traffic.

Bash

# Install UFW
sudo apt install ufw

# Set Default Rules
sudo ufw default deny incoming
sudo ufw default allow outgoing

# Allow Critical Ports
sudo ufw allow 22/tcp   # SSH
sudo ufw allow 80/tcp   # HTTP
sudo ufw allow 443/tcp  # HTTPS

# Enable Firewall
sudo ufw enable

Step 9: Verification

Check service status (Should all be RUNNING).

Bash

sudo supervisorctl status

Access your site: Open http://localhost (or your IP address) in your browser.

1 Like

Dear Kibet_Sang,

Thank you so much, I have fixed all my error and my erpnext is now running properly !

I just have an issue generating PDF but I think it’s normal because i don’t have the good version of wkhtmltopdf

I continue to discover this wonderful software…

Regards,

PoyPoy

1 Like

Post the error here will help, for pdf generating

Here is my own guide to fix the issues that has been encountered during the installation

I begin by this guide : Frappe & ERPNext v16 Installation Ubuntu 25 - #20 by poypoy1-dot

When I start my Bench instance, I encountered several little erros, I fix them by upgrading some libs.

After that my Bench start runs correctly and I access the ERP.

I test the ERP by saving some datas and I have issues saving “ADDRESSES”, I post a thread on the forum to have some help → Error in saving Customer Address

I discovered that there was a desynchronisation between my server and the ErpNext Cloud (I had previously created an account to test the application).

So I had DOCTYPEs that were not synchronised, data was missing…

I also checked the versions of all my libraries and Python was only 3.12 instead of 3.14…

So I looked for a solution on the forum and followed this protocol to correctly update FRAPPE, ERPNext and HRMS to v16
Guide to upgrading bench Frappe and ERPNext from v15 to v16 on Debian 12 - #15 by Rick-Hard89

So I ended up with library UPGRADES and UPGRADES in Frappe and ERPNext…

It wasn’t easy because the build takes a long time on my VM…

After a few hours of struggle, I managed to get a stable system.

So I finalised my installation by switching to PRODUCTION mode, following this guide → Enterprise Production Setup & Security (ERPNext v16 / Ubuntu 25)

I restart all the services and my ERPNext runs well. I save some datas : customer, addresses, items, quotation, invoices but an error remain when I want to print a PDF.

An error due to the lack of wkhtmltopdf library…
I decide to install the last version of this library by running some piece of code :

apt install wkhtmltopdf
....
depends of xfont...
apt install xfont...

wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6.1-2/wkhtmltox_0.12.6.1-2.jammy_amd64.deb
dpkg --install wkhtmltox_0.12.6.1-2.jammy_amd64.deb

And finally all is running well !

Everything good until Step 9:

‘sudo supervisorctl status’ - returned (everything else just fine):

frappe-bench-redis:frappe-bench-redis-queue FATAL Exited too quickly (process log may have details)

Apart from that - production setup appears to be just fine - ERPNext, Frappe HR, & so on

reboot & still good