ERPNext in Production

Table of Contents

ERPNext in Production

๐Ÿฐ The Kingdom of Frappe: A Developerโ€™s Quest to Rule ERPNext!

Once upon a time, in the Land of Debian, a brave developer set forth to build their own ERP Kingdom using the mighty Frappe Framework and the legendary ERPNext.

This is their taleโ€ฆ


โš”๏ธ Chapter 1: Preparing the Kingdom (Prerequisites)

Before you can rule, you must fortify your castle (Debian system) with the right tools!

# ๐Ÿ—๏ธ Build the foundation (install dependencies)
sudo apt update && sudo apt upgrade -y
sudo apt install -y python3-dev python3-pip python3-setuptools python3-venv \
    build-essential git mariadb-server mariadb-client redis-server \
    curl software-properties-common libmysqlclient-dev libffi-dev \
    libssl-dev cron sudo

# โšก Power up with Node.js & Yarn (for the frontend magic)
curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash -
sudo apt install -y nodejs
sudo npm install -g yarn

# โœ๏ธ The Royal Scribe (wkhtmltopdf for PDF reports)
sudo apt install -y wkhtmltopdf

๐Ÿ‘‘ Chapter 2: Summoning the Bench (Installation)

The Bench is the scepter of powerโ€”it commands Frappe and ERPNext!

# ๐Ÿฐ Install the mighty Bench CLI
sudo pip3 install frappe-bench

# ๐Ÿ—๏ธ Forge a new Bench (a directory for your kingdom)
bench init frappe-bench --frappe-branch version-15
cd frappe-bench

# ๐ŸŽฏ Create your first castle (site)
bench new-site castle.localhost --mariadb-root-password StrongPassword123

๐Ÿ”ฎ Chapter 3: The ERPNext Scroll (Installing ERPNext)

Now, summon the legendary ERPNext to your kingdom!

# ๐Ÿ“œ Fetch the ERPNext scroll (source code)
bench get-app erpnext https://github.com/frappe/erpnext --branch version-15

# ๐Ÿ† Install ERPNext into your castle
bench --site castle.localhost install-app erpnext

๐Ÿš€ Chapter 4: Launching the Kingdom (Development Mode)

Time to raise the banners and start your reign!

# ๐ŸŽช Start the Frappe & ERPNext festival (development server)
bench start

๐ŸŽ‰ Huzzah! Your kingdom is now live at:
๐Ÿ‘‰ http://localhost:8000

Login: Administrator
Password: (the one you set during new-site)


โš’๏ธ Chapter 5: Customizing Your Kingdom

A true ruler shapes their domain!

๐Ÿ› ๏ธ Ways to Customize:

  1. Create new Doctypes (Royal Decrees)

    bench new-doctype "Tax Law"
    
  2. Modify existing Doctypes (Edit the Royal Archives)

    • Go to Developer Mode โ†’ Customize Form
  3. Build a Custom App (Found a New City!)

    bench new-app trade_port
    bench --site castle.localhost install-app trade_port
    

๐Ÿฐ Chapter 6: The Grand Deployment (Production)

Your kingdom must stand strong in the real world!

โš”๏ธ Steps to Rule in Production:

  1. Harden Your Castle (Security & Performance)

    bench setup production king
    sudo bench setup nginx
    sudo bench setup supervisor
    
  2. Raise the Moat (Firewall & SSL)

    sudo apt install ufw -y
    sudo ufw allow 22,80,443
    sudo ufw enable
    sudo certbot --nginx
    
  3. Train the Guards (Automated Backups)

    bench setup backups
    
  4. Launch the Kingdom!

    bench restart
    

๐ŸŽ‡ Long live the King/Queen! Your ERPNext kingdom is now live in production!


๐Ÿ“œ Epilogue: The Developerโ€™s Legacy

You have:
โœ… Built a Frappe & ERPNext kingdom
โœ… Customized it to your royal will
โœ… Deployed it to rule forever

Now, go forth and conquer business automation! ๐Ÿš€

Need reinforcements? Ask in the Frappe Forum or ERPNext Community!

โš”๏ธ The Endโ€ฆ or Just the Beginning? โš”๏ธ


๐Ÿ‰ Dealing with Python’s Externally Managed Environment in Debian

Ah, the dreaded Debian Python protection spell! This is Debian’s way of preventing pip from making system-wide changes that could conflict with apt packages. Let me guide you through several ways to bypass this safely:

๐Ÿ›ก๏ธ Option 1: The Safe Way (Using Virtual Environment)

# Install required system packages
sudo apt install python3-venv python3-dev

# Create a virtual environment
python3 -m venv ~/frappe-env

# Activate the environment
source ~/frappe-env/bin/activate

# Now install frappe-bench safely
pip install frappe-bench

โš”๏ธ Option 2: The Brave Way (Using –break-system-packages)

# Only do this if you understand the risks!
sudo -H pip3 install frappe-bench --break-system-packages

๐Ÿง™ Option 3: The Wizard’s Way (Using pipx)

# First install pipx
sudo apt install pipx
pipx ensurepath

# Then install frappe-bench in its own isolated environment
pipx install frappe-bench

๐Ÿฐ Option 4: The Debian-approved Way

# Install all dependencies first
sudo apt install python3-pip python3-setuptools python3-wheel

# Then use the --user flag to install locally
pip3 install --user frappe-bench

# Add local bin to PATH
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc

๐Ÿ’ก Pro Tip:

After installation, verify with:

bench --version

Remember, the virtual environment method (Option 1) is the safest and most recommended approach for Frappe development. It keeps your system Python clean and prevents conflicts with Debian’s package manager.

Tags :