How to install ERPNext15.59.0 on Ubuntu24 | 如何在Ubuntu24上部署ERPNext15.59.0

erpnext官方文档
bench官方文档

如果有部署方面的问题可 这里 问问,支持Alma9.5上部署

前奏

Ubuntu24
8G/16G/172.16.186.117/24
NAT网络模式



rambo@ubuntu24-1:~$ cat /etc/apt/sources.list.d/ubuntu.sources
Types: deb
URIs: http://cn.archive.ubuntu.com/ubuntu/
Suites: noble noble-updates noble-backports
Components: main restricted universe multiverse
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg

Types: deb
URIs: http://security.ubuntu.com/ubuntu/
Suites: noble-security
Components: main restricted universe multiverse
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg


rambo@ubuntu24-1:~$ sudo apt update -y



# 安装依赖
rambo@ubuntu24-1:~$ sudo apt install -y python3 python3-pip python3-dev python3-setuptools \
redis-server mariadb-server libmysqlclient-dev libssl-dev \
libmysqlclient-dev  libjpeg8-dev liblcms2-dev \
libsasl2-dev libldap2-dev build-essential libssl-dev \
libffi-dev libxml2-dev libjpeg8-dev \
libmysqlclient-dev libsqlite3-dev



# 启动redis
rambo@ubuntu24-1:~$ sudo systemctl restart redis-server && sudo systemctl enable redis-server


# 初始化数据库
rambo@ubuntu24-1:~$ sudo systemctl status mysqld
rambo@ubuntu24-1:~$ sudo mysql_secure_installation
Enter current password for root (enter for none):         # 回车
Switch to unix_socket authentication [Y/n] y
Change the root password? [Y/n] y
New password: 
Re-enter new password:                   # 6个a
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


# 创建数据库
rambo@ubuntu24-1:~$ mysql -u root -p
CREATE USER 'frappe'@'localhost' IDENTIFIED BY 'aaaaaa';
GRANT ALL PRIVILEGES ON `frappe_%`.* TO 'frappe'@'localhost';
FLUSH PRIVILEGES;



# 安装 Node.js 和 Yarn
# 安装 Node.js 20.x(确保安装与 ERPNext 兼容的版本)
rambo@ubuntu24-1:~$ curl -sL https://deb.nodesource.com/setup_20.x | sudo -E bash -
rambo@ubuntu24-1:~$ sudo apt install -y nodejs

# 安装Yarn
rambo@ubuntu24-1:~$ curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
rambo@ubuntu24-1:~$ echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
rambo@ubuntu24-1:~$ sudo systemctl daemon-reload && sudo apt update
rambo@ubuntu24-1:~$ sudo apt install --no-install-recommends yarn


# 安装wkhtmltopdf
wkhtmltopdf 是一个依赖于ERPNext生成PDF报告的工具。你可以通过以下命令安装:
rambo@ubuntu24-1:~$ sudo apt install -y wkhtmltopdf


安装 Bench 工具

Bench 是一个用于管理 Frappe 和 ERPNext 项目的命令行工具
安装pipx
rambo@ubuntu24-1:~$ sudo apt install pipx
rambo@ubuntu24-1:~$ pipx ensurepath
Success! Added /home/rambo/.local/bin to the PATH environment variable.

Consider adding shell completions for pipx. Run 'pipx completions' for instructions.

You will need to open a new terminal or re-login for the PATH changes to take effect.

Otherwise pipx is ready to go! ✨ 🌟 ✨


rambo@ubuntu24-1:~$ pipx install ansible
  installed package ansible 11.5.0, installed using Python 3.12.3
  These apps are now globally available
    - ansible-community
⚠️  Note: '/home/rambo/.local/bin' is not on your PATH environment variable. These apps will not be globally accessible
    until your PATH is updated. Run `pipx ensurepath` to automatically add it, or manually modify your PATH in your shell's
    config file (i.e. ~/.bashrc).
done! ✨ 🌟 ✨




rambo@ubuntu24-1:~$ sudo pipx install frappe-bench


# 创建一个新的 Bench 环境,并为 ERPNext 项目创建一个文件夹:
rambo@ubuntu24-1:~$ bench init frappe-bench --frappe-branch version-15
rambo@ubuntu24-1:~$ cd frappe-bench


rambo@ubuntu24-1:~/frappe-bench$ sudo vim sites/common_site_config.json
{
 "background_workers": 1,
 "file_watcher_port": 6787,
 "frappe_user": "rambo",
 "gunicorn_workers": 17,
 "live_reload": true,
 "rebase_on_pull": false,
 "redis_cache": "redis://127.0.0.1:6379",
 "redis_queue": "redis://127.0.0.1:6379",             # 修改redis的端口,从13000改成redis实际的端口
 "redis_socketio": "redis://127.0.0.1:6379",
 "restart_supervisor_on_update": false,
 "restart_systemd_on_update": false,
 "serve_default_site": true,
 "shallow_clone": true,
 "socketio_port": 9000,
 "use_redis_auth": false,
 "webserver_port": 8000
}


rambo@ubuntu24-1:~/frappe-bench$ bench build


重新生成 Supervisor 配置
rambo@ubuntu24-1:~/frappe-bench$ bench setup supervisor
复制配置到系统目录
rambo@ubuntu24-1:~/frappe-bench$ sudo cp config/supervisor.conf  /etc/supervisor/conf.d/frappe.conf
重新加载 Supervisor 并启动
rambo@ubuntu24-1:~/frappe-bench$ sudo supervisorctl reread && sudo supervisorctl update
启动服务(或者 restart 全部)
rambo@ubuntu24-1:~/frappe-bench$ sudo supervisorctl restart all



在Bench环境中安装ERPNext应用:
rambo@ubuntu24-1:~/frappe-bench$ bench get-app erpnext --branch version-15


创建站点
创建一个新的站点并安装ERPNext应用到该站点:
rambo@ubuntu24-1:~/frappe-bench$ bench new-site  test01.com
MySQL root password:                  # 这里是输入数据库的密码,6个a
Warning: MariaDB version ['10.11', '11'] is more than 10.8 which is not yet tested with Frappe Framework.

Installing frappe...
Updating DocTypes for frappe        : [========================================] 100%
Set Administrator password:           # 这里定义登陆erpnext时的Administrator用户的密码
Re-enter Administrator password: 
Updating Dashboard for frappe
test01.com: SystemSettings.enable_scheduler is UNSET
*** Scheduler is disabled ***



rambo@ubuntu24-1:~/frappe-bench$ ls sites/
apps.json  apps.txt  assets  common_site_config.json  test01.com



# 配置 Nginx 和 Supervisor(可选)
在生产环境中,通常需要配置Nginx作为反向代理,并使用 Supervisor 来管理进程。可以通过以下命令进行配置:
rambo@ubuntu24-1:~/frappe-bench$ bench setup nginx
Port configuration list:

Site test11.com assigned port: 80


rambo@ubuntu24-1:~/frappe-bench$ bench setup supervisor


# 激活bench的虚拟环境
rambo@ubuntu24-1:~/frappe-bench$ source /home/rambo/.local/share/pipx/venvs/frappe-bench/bin/activate

配置生产环境(Nginx)
(frappe-bench) rambo@ubuntu24-1:~/frappe-bench$ bench setup production rambo
注:这句中的rambo 是Linux的用户名,会为它配置 Supervisor 和 Nginx

(frappe-bench) rambo@ubuntu24-1:~/frappe-bench$ sudo service nginx restart
(frappe-bench) rambo@ubuntu24-1:~/frappe-bench$ sudo supervisorctl reread
No config updates to processes
(frappe-bench) rambo@ubuntu24-1:~/frappe-bench$ sudo supervisorctl update



# 安装ERPNext
(frappe-bench) rambo@ubuntu24-1:~/frappe-bench$ bench --site test01.com install-app erpnext


(frappe-bench) rambo@ubuntu24-1:~/frappe-bench$ sudo chown -R rambo:www-data /home/rambo/frappe-bench/sites
(frappe-bench) rambo@ubuntu24-1:~/frappe-bench$ sudo chmod -R 755 /home/rambo/frappe-bench/sites
(frappe-bench) rambo@ubuntu24-1:~/frappe-bench$ sudo chmod o+x /home/rambo


(frappe-bench) rambo@ubuntu24-1:~/frappe-bench$ sudo netstat -anpt|grep 8000
tcp        0      0 127.0.0.1:8000          0.0.0.0:*               LISTEN      17461/python 


(frappe-bench) rambo@ubuntu24-1:~/frappe-bench$ sudo vim /etc/nginx/sites-available/erpnext15
server {
    listen 80;
    server_name test111.com;          # 替换成你自己的域名或服务器IP

    # gzip 压缩
    gzip on;
    gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

    # 客户端请求大小限制
    client_max_body_size 20M;

    # 静态文件缓存
    location /assets {
        root /home/rambo/frappe-bench/sites;
        try_files $uri =404;
        expires max;
        add_header Cache-Control public;
    }

    location / {
        proxy_pass http://127.0.0.1:8000;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }

    location ~ ^/socket.io {
        proxy_pass http://127.0.0.1:9000;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header Host $host;
        proxy_read_timeout 120;
    }

    location /websocket {
        proxy_pass http://127.0.0.1:9000;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header Host $host;
        proxy_read_timeout 120;
    }

    location /assets/.*/.*\.js {
        add_header Cache-Control "public, max-age=31536000, immutable";
    }

    location /assets/.*/.*\.css {
        add_header Cache-Control "public, max-age=31536000, immutable";
    }

    location ~ ^/private/ {
        internal;
        try_files /$uri =404;
    }

    location ~ ^/files/ {
        root /home/rambo/frappe-bench/sites;
        try_files /$uri =404;
    }
}


(frappe-bench) rambo@ubuntu24-1:~/frappe-bench$ sudo ln -s /etc/nginx/sites-available/erpnext15  /etc/nginx/sites-enabled/erpnext
(frappe-bench) rambo@ubuntu24-1:~/frappe-bench$ sudo nginx -t && sudo systemctl restart nginx
(frappe-bench) rambo@ubuntu24-1:~/frappe-bench$ sudo supervisorctl restart all


在宿机的hosts文件中做域名和IP的映射


在宿机上访问域名(test111.com)可看到erpnext15的页面,邮箱和密码如下:
在执行 bench new-site test01.com 时,系统提示你设置了 Administrator密码
Set Administrator password:                # 当时输入的是6个a


如果忘记了管理员密码可用命令重置:
bench --site test01.com set-admin-password 新密码




界面更换修改中文




更换logo


posted @ 2025-04-25 17:41  Linux大魔王  阅读(616)  评论(0)    收藏  举报