ERPNext 在 Ubuntu 24.04 LTS 中的安装笔记 Step by Step

文章目录 | Table of Contents

  1. ERPnext 简介
  2. 先决条件
  3. 安装步骤
  4. 总结 & 引用

先决条件 | Prerequisites

系统环境要求

  • Ubuntu 24.04
  • A user with sudo privileges
  • Python 3.11+
  • pip 20+
  • MariaDB 10.3.x
  • Node.js 18
  • Yarn 1.12+

硬件要求

  • 2 Process 2 Core
  • 4GB ram
  • 40GB Storage
  • Intenet

安装步骤 | Installtion Steps

包升级和创建新用户

  1. Update and Upgrade Packages

    sudo apt-get update -y && sudo apt-get upgrade -y
  2. Create a New user

    sudo adduser **Your-user-name**
    #Fill in the information as prompted
    sudo usemod -aG sudo **Your-user-name**
    su **Your-user-name**
    #Enter your password
    cd ~ 

安装环境需要的包

  1. Install Git

    sudo apt-get install git -y
  2. Install Python Dependencies

    sudo apt-get install python3-dev -y
    sudo apt-get install python3-setuptools -y
    sudo apt-get install python3-pip -y
    sudo apt install python3.12-venv -y
  3. Install MariaDB and Configuration it

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

    在执行mysql_secure_installtion 之后请按以下步骤设置

    • 设置root密码
    • 删除 anonymous users
    • 允许root 远程登录
    • 删除test database
    • Reload privilege tables

      image-20250208142432980.png

      image-20250208142527576.png

    编辑 MariaDB 配置文件

    sudo cp /etc/mysql/my.cnf /opt/my.cnf.back
    sudo nano /etc/mysql/my.cnf 
    #ctrl +x  y save
    sudo systemctl restart mariadb

    在my.cnf最末行添加如下内容

    [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
  4. Install Redis Server

    sudo apt-get install redis-server -y
  5. Install CURL, Node.js, NPM, and Yarn and wkhtmltopdf

    #CURL
    sudo apt install curl
    #Node js
    curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
    source ~/.profile
    nvm install 18
    #NPM
    sudo apt-get install npm -y
    #Yarn
    sudo npm install -g yarn -y
    #wkhtmltopdf
    sudo apt-get install xvfb libfontcofig wkhtmltopdf -y

Setting Up Frappe Bench

  1. Install Frappe Bench

    sudo -H pip3 install frappe-bench --break-system-packages
    sudo -H pip3 install ansible --break-system-packages
  2. Initialize Frappe Bench

    bench init frappe-bench --frappe-branch version-15
    ls 
    
    cd frappe-bench
    
    #change directory permissions
    chmod -R o+rx /home/**Your-erp-users**
  3. Create a New site

    bench new-site **site-name**
    #enter you database root password
    #setings Administrator password
  4. Install ERPnext APPS

    bench get-app payments
    bench get-app --branch version-15 erpnext
    bench --site **site-name** install-app erpnext
    
    
    bench use **site-name**
  5. 启用调度程序并禁用维护模式

    1. bench --site [site-name] enable-scheduler

      • 启用 ERPNext 站点的后台任务调度程序。
      • ERPNext 依赖调度程序执行定时任务(如生成报告、发送邮件、处理队列任务等)。
      • 如果不启用调度程序,某些功能可能无法正常工作。
    2. bench --site [site-name] set-maintenance-mode off

      • 将站点从维护模式切换到正常模式。
      • 在维护模式下,站点对普通用户不可用,只有管理员可以访问。
      • 关闭维护模式后,站点恢复正常运行,用户可以访问。
  6. 配置生产环境

    1. sudo bench setup production **erp-user**

      • 将 ERPNext 配置为生产模式。
      • 该命令会:

        • 配置 Gunicorn(用于处理 Python 请求的 WSGI 服务器)。
        • 配置 Supervisor(用于管理后台进程)。
        • 确保站点在生产环境中以最佳性能运行。
      • [**erp-user**] 是运行 Frappe/ERPNext 的系统用户(通常为 frappe)。
    2. bench setup nginx

      • 配置 Nginx 作为反向代理服务器。
      • Nginx 负责处理外部请求并将其转发给 Gunicorn。
      • 该命令会自动生成 Nginx 配置文件并启用站点。
    3. sudo supervisorctl restart all

      • 重启所有由 Supervisor 管理的进程。
      • 确保所有服务(如 Gunicorn、后台工作进程等)使用最新的配置。
    4. sudo bench setup production **erp-user**(重复)

      • 再次运行以确保所有生产配置已正确应用。

访问站点

  • 在生产模式下,ERPNext 通过 Nginx 提供服务,默认使用 HTTP(80 端口)或 HTTPS(443 端口)。
  • 你可以直接通过服务器的 IP 地址或域名访问站点,无需指定端口号(如 http://your-server-ip)。

总结 和 引用 | Conclusion & References

References:

How to Install ERPNext Version 15 on Ubuntu 24.04: A Step-by-Step Guide -
https://syncbricks.com/how-to-install-erpnext-version-15-on-ubuntu-24-04-a-step-by-step-guide/

Youtube - https://www.youtube.com/watch?v=Q9D2wbrC6i8

Chat GPT & DeepSeek