基于ubuntu server 20.04安装ERPNext Version-13之完全新手指南

此文基于官网贴子:

https://discuss.erpnext.com/t/install-frappe-erpnext-v13-beta-from-scratch-100-guarantee-22-steps-on-ubuntu-20-04/69565

余总的gitee:

https://gitee.com/yuzelin/erpnext-chinese-docs/blob/master/安装文档/基于ubuntu20.04安装ERPNext Version-13 新手版.md

步骤如下

  1. 准备一台装好ubuntu20.04的服务器,本地虚拟机或者VPS皆可,注意这里的系统指的是Ubuntu server,不是桌面版的,桌面版的系统安装会状况百出!!!虚拟机的网络要用桥接模式。

  2. 设置root密码

    sudo passwd root
    
  3. 添加用户

    adduser USERNAME
    #用户名USERNAME换成自己计划使用的用户名,如果直接使用已存在且有sudo权限的账号,这一步和下面这一步就可跳过。
    
  4. 将用户设置sudo权限:

    usermod -aG sudo USERNAME
    #记得把命令行里的USERNAME改成自己刚设置的用户名
    
  5. 通过ssh登录root用户

    #虚拟机需要先设置将端口22开放才能通过ssh连接
    vim /etc/ssh/sshd_config
    
    按i,移动光标打到以下内容修改:
    
    #Port 22
    改为
    Port 22
    
    #PermitRootLogin prohibit-password
    改为
    PermitRootLogin yes
    
    修改好按ESC,shift+:,输入wq回车
    
    重启服务
    /etc/init.d/ssh restart
    
  6. 替换国内镜像源,下面用的是清华的镜像源,操作如下(root用户可不输入sudo):

    1.备份
    sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak 
    
    2.修改
    sudo vim /etc/apt/sources.list
    
    3.按ggVG进行全选,按d进行删除
    4.将下面源粘贴
    5.按esc,再按shift+:,输入wq回车(这步是保存退出)
    
    # 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
    deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
    # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
    deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
    # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
    deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
    # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
    deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse
    # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse
    
    # 预发布软件源,不建议启用
    # deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse
    # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse
    
  7. 更新并重启

    apt update && apt upgrade -y && shutdown -r now
    
  8. 下载node.js

    curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
    
  9. 安装操作系统级依赖

    apt install -y nodejs mariadb-server-10.3 redis-server python3-pip nginx python3-testresources
    #最新的10.5版本的Mariadb数据库安装后会报错,需要更改默认的数据库引擎。建议10.3版本。——来自Jason Zhang的文档,所以我这里又在Mariadb后面加上了个版本号
    
  10. 用nano编辑my.cnf文件

nano /etc/mysql/my.cnf

将光标移动到最后空白行,复制以下文本内容,ctrl + O,回车确认,ctrl + X返回命令行

[mysqld]
character-set-client-handshake = FALSE 
character-set-server = utf8mb4 
collation-server = utf8mb4_unicode_ci 

[mysql]
default-character-set = utf8mb4
  1. 重启sql
service mysql restart
  1. mysql的安全配置
mysql_secure_installation

第一个输入数据库密码对话框出来的时候,直接敲回车代表没有密码,剩下的按照下面选择:

Enter current password for root (enter for none): 
#这里直接回车
Set root password? [Y/n] Y
New password:
Re-enter new password:
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
  1. 输入上面新设置的数据库root账号密码,进入数据库命令行,并执行下面的语句

    mysql -u root -p
    
    USE mysql; 
    UPDATE user SET plugin=' ' WHERE user ='root'; 
    FLUSH PRIVILEGES;
    exit;
    
  2. 【重要】关闭ssh终端,重新以自己“新创建的用户名”和密码登录

  3. 安装yarn

    sudo npm install -g yarn
    
    #保险起见,还需要将刚刚的yarn,node,npm添加运行权限。 sudo chmod +x /usr/bin/node. 默认有运行权限。——Jason Zhang
    
  4. 查看版本,对照一下,这一步不做也行

    node -v && npm -v && python3 -V && pip3 -V && yarn -v
    
  5. 安装bench,即erpnext系统的命令行管理工具,类似windows系统的程序管理器。

    sudo pip3 install frappe-bench
    
  6. 安装git,下一步bench init会报错缺少git,阿里云可以省了这一步。

    sudo apt install git
    
  7. 使用bench命令安装frappe框架,记得把frappe-bench(下方的version-13后面的名字)改成自己想要的名字,这一步时间比较长,别着急,代码库已经加了码云地址参数。如果网络超时失败,可重新运行该命令,重新运行之前需使用命令 rm -r myfrappe 删除之前生成的目录。

    bench init --frappe-branch version-13 frappe-bench --frappe-path=https://gitee.com/phipsoft/frappe
    
    #下面这段是警告说pip有新版本,可忽略
    WARNING: You are using pip version 21.0.1; however, version 21.1 is available.
    You should consider upgrading via the '/home/frappe/frappe-bench/env/bin/python -m pip install --upgrade pip' command.
    
    #删掉目录重来,还是会报,有时候报很多错,有时候报一个无法下载某个东东,但还是报成功
    SUCCESS: Bench frappe-bench initialized
    
    #如报错,sudo rm -r frappe-bench,重新装过,然后看运气会有成功的时候
    
  8. 进入bench目录,同样记得改名

    cd frappe-bench
    
  9. 新建站点,名字自己取,安装时会提示输入数据库root账号的密码, 新站点数据库及erp系统管理员账号administator 密码,其中数据库root账号密码须与上述数据库安装时密码一致,其它密码自己取 --db-password xxx 也可以命令行参数中直接输入好密码,--mariadb-root-password yyyy --admin-password zzzz

    bench new-site mysite
    
  10. 下载安装erpnext

    bench get-app --branch version-13 erpnext https://gitee.com/phipsoft/erpnext
    
  11. 安装erpnext

    bench install-app erpnext https://gitee.com/phipsoft/erpnext
    
  12. 设置为生产环境,即用supervisorctl管理所有进程,使用nginx做反向代理,USERNAME换成第3步新建的账号,大功告成。

    sudo bench setup production USERNAME
    
  13. 安装完后可查看一下是否有活动的wokers

    bench doctor
    
    #正常情况下会显示如下:
    -----Checking scheduler status-----
    Scheduler disabled for erpnext
    Scheduler inactive for erpnext
    Workers online: 3
    -----erpnext Jobs-----
    
  14. 以上完成后查看一下安装了哪些app

    bench version 
    

    正常会显示以下三个app

    ebclocal 0.0.1
    erpnext 13.1.0
    frappe 13.1.2
    
  15. 如果是虚似机安装,需要防火墙入站打开80端口。

    ufw allow 80
    
    sudo ufw status verbose
    
    #打开后显示如下:
    root@erpnext:~# ufw allow 80
    Rule added
    Rule added (v6)
    root@erpnext:~# sudo ufw status verbose
    Status: active
    Logging: on (low)
    Default: deny (incoming), allow (outgoing), deny (routed)
    New profiles: skip
    
    To                         Action      From
    --                         ------      ----
    22/tcp                     ALLOW IN    Anywhere                  
    22                         ALLOW IN    Anywhere                  
    80                         ALLOW IN    Anywhere                  
    22/tcp (v6)                ALLOW IN    Anywhere (v6)             
    22 (v6)                    ALLOW IN    Anywhere (v6)             
    80 (v6)                    ALLOW IN    Anywhere (v6) 
    
  16. 阿里云服务器要在安全组里添加80的入站端口号。

附注:安装ebclocal汉化APP

  1. 获取APP

    bench get-app --branch master https://gitee.com/yuzelin/ebclocal.git
    
  2. 安装APP

    bench install-app ebclocal
    
  3. 用浏览器(推荐 Chrome或Firefox)输入IP或域名,登录系统,用户名administrator,密码是第21步admin-password密码。设

常见问题

  1. wkhtmltopdf安装时出现字体库依赖无法安装等错误 参考了这个https://askubuntu.com/questions/604029/dependency-problems-with-wkhtmltopdf-when-trying-to-install-latest-version,最后是以下命令解决了

    sudo apt-get -f install
    
  2. 通过打印转PDF时出现乱码 参考这个帖子https://www.taodudu.cc/news/show-1772808.html,用以下命令安装字体

    sudo apt-get install ttf-wqy-zenhei -y
    
posted @ 2021-04-25 10:10  流氓锈才  阅读(1853)  评论(0)    收藏  举报