1.如果当前登录的是root用户,请新建一个用于安装ERP的sudo用户。
adduser [frappe-user]
usermod -aG sudo [frappe-user]
2. 更新系统并重启系统。
apt update && apt upgrade -y && shutdown -r now
3.安装 curl
sudo apt install curl
4.安装 nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
这个命令会自动下载并安装nvm脚本
4.1如果你无法访问GitHub,请把raw.githubusercontent.com的ip地址加入到host文件最后一行。(报443错误的大部分情况都可以通过这个方法解决)
sudo nano /etc/hosts
#例如:
185.199.111.133 raw.githubusercontent.com
4.3在nvm安装完成后,你需要在命令行中输入以下命令来使nvm生效:
source ~/.bashrc
5.把nvm源临时改为国内,提高node18的安装速度
NVM_NODEJS_ORG_MIRROR=https://npm.taobao.org/mirrors/node
6.安装 Node18
nvm install 18
6.1把npm源改为国内
npm config set registry=http://registry.npm.taobao.org/
#查看npm当前源地址
npm config get registry
6.2安装Canvas
npm install canvas
7.安装HTML to PDF
wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6.1-2/wkhtmltox_0.12.6.1-2.jammy_amd64.deb
sudo dpkg -i wkhtmltox_0.12.6.1-2.jammy_amd64.deb
7.1检查wkhtmltopdf 库是否正确安装并确认是否为所需版本
wkhtmltopdf –version
#显示wkhtmltopdf 0.12.6.1 (with patched qt) 即是正确版本
#如果出现如下错误:
~$ sudo dpkg -i wkhtmltox_0.12.6.1-2.jammy_amd64.deb
Selecting previously unselected package wkhtmltox.
(Reading database … 74415 files and directories currently installed.)
Preparing to unpack wkhtmltox_0.12.6.1-2.jammy_amd64.deb …
Unpacking wkhtmltox (1:0.12.6.1-2.jammy) …
dpkg: dependency problems prevent configuration of wkhtmltox:
wkhtmltox depends on fontconfig; however:
Package fontconfig is not installed.
wkhtmltox depends on libjpeg-turbo8; however:
Package libjpeg-turbo8 is not installed.
wkhtmltox depends on libxrender1; however:
Package libxrender1 is not installed.
wkhtmltox depends on xfonts-75dpi; however:
Package xfonts-75dpi is not installed.
wkhtmltox depends on xfonts-base; however:
Package xfonts-base is not installed.
dpkg: error processing package wkhtmltox (–install):
dependency problems – leaving unconfigured
Processing triggers for man-db (2.10.2-1) …
Errors were encountered while processing:
wkhtmltox
运行sudo apt install -f 安装依赖即可
8.安装操作系统所需的各种依赖包
sudo apt install -y python3.10-dev python3-setuptools python3-pip python3-distutils python3.10-venv software-properties-common mariadb-server mariadb-client redis-server nodejs xvfb libfontconfig libmysqlclient-dev nginx git ansible ttf-wqy-zenhei ttf-wqy-microhei
9.将Python的pip源改成国内源,有助于后面安装frappe时提高速度和成功率。
pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/
pip config set install.trusted-host mirrors.aliyun.com
10. 接下来开始配置MariaDB,用nano编辑my.cnf文件。
sudo nano /etc/mysql/my.cnf
10.1将光标移动到最后空白行,复制以下文本内容,粘贴后注意格式和换行要同下方,Ctrl + S保存,Ctrl + X返回命令行。
[mysqld]
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
[mysql]
default-character-set = utf8mb4
10.2重启sql
sudo service mysql restart
10.3开始mysql的安全配置
sudo mysql_secure_installation
第一个输入数据库密码对话框出来的时候,直接敲回车代表没有密码,剩下的按照下面选择:
# 注:运行结果用 ··· 代替
Enter current password for root (enter for none): # 输入root(mysql)的密码,初次安装默认没有,直接回车
…
Switch to unix_socket authentication [Y/n] n # 是否切换到unix套接字身份验证[Y/n]
…
Change the root password? [Y/n] y #是否设置root用户密码
New password: # 新密码
Re-enter new password: # 再次输入密码
…
Remove anonymous users? [Y/n] y # 是否删除匿名用户,建议删除
…
Disallow root login remotely? [Y/n] n # 是否禁止root远程登录,建议不开启
…
Remove test database and access to it? [Y/n] n # 是否删除test数据库,可以保留
…
Reload privilege tables now? [Y/n] y # 是否重新加载权限表,也可以直接回车
…
Thanks for using MariaDB! # 看到这句话证明设置成功
11.安装 Yarn
npm install -g yarn
#yarn config get registry查看源, 如果官方源请设置为以下国内源
yarn config set registry https://registry.npmmirror.com/ –global && \
yarn config set disturl https://npmmirror.com/package/dist –global && \
yarn config set sass_binary_site https://cdn.npmmirror.com/binaries/node-sass –global && \
yarn config set electron_mirror https://registry.npmmirror.com/binary.html?path=electron/ –global && \
yarn config set puppeteer_download_host https://registry.npmmirror.com/binary.html –global && \
yarn config set chromedriver_cdnurl https://cdn.npmmirror.com/binaries/chromedriver –global && \
yarn config set operadriver_cdnurl https://cdn.npmmirror.com/binaries/operadriver –global && \
yarn config set phantomjs_cdnurl https://cdn.npmmirror.com/binaries/phantomjs –global && \
yarn config set selenium_cdnurl https://cdn.npmmirror.com/binaries/selenium –global && \
yarn config set node_inspector_cdnurl https://cdn.npmmirror.com/binaries/node-inspector –global
npm set registry https://registry.npmmirror.com/
npm set sass_binary_site https://cdn.npmmirror.com/binaries/node-sass
npm set electron_mirror https://registry.npmmirror.com/binary.html?path=electron/
npm set puppeteer_download_host https://registry.npmmirror.com/binary.html
npm set chromedriver_cdnurl https://cdn.npmmirror.com/binaries/chromedriver
npm set operadriver_cdnurl https://cdn.npmmirror.com/binaries/operadriver
npm set phantomjs_cdnurl https://cdn.npmmirror.com/binaries/phantomjs
npm set selenium_cdnurl https://cdn.npmmirror.com/binaries/selenium
npm set node_inspector_cdnurl https://cdn.npmmirror.com/binaries/node-inspector
11.1查看版本,对照一下,这一步不做也行.
node -v && npm -v && python3 -V && pip3 -V && yarn -v
12.安装bench,即erpnext系统的命令行管理工具,类似windows系统的程序管理器。
sudo -H pip3 install frappe-bench
13. 使用bench命令安装frappe框架。frappe-bench是安装frappe框架的目录名称。
bench init –frappe-branch version-15 frappe-bench –frappe-path=https://gitee.com/mirrors/frappe –verbose
如果安装失败,可重新运行该命令,重新运行之前需使用命令 rm -r frappe-bench 删除之前生成的目录。
14. 再将安装的系统用户分配一下执行权限。
chmod -R o+rx /home/[frappe-user]/
15. 进入bench目录
cd frappe-bench
16. 新建站点,把下方的{sitename}替换为你的站点名称。
bench new-site {sitename}
#不需要的站点用bench drop-site {sitename} –force命令删除
17. 下载APP
bench get-app payments
bench get-app erpnext
bench get-app hrms
17.1如果你的网络无法访问GitHub.com请使用以下命令从国内仓库下载APP
bench get-app –branch version-15 https://gitee.com/qinyanwan/payments
bench get-app –branch version-15 erpnext https://gitee.com/mirrors/erpnext
bench get-app –branch version-15-beta https://gitee.com/qinyanwan/hrms
17.2安装APP
bench –site {sitename} install-app payments
bench –site {sitename} install-app erpnext
bench –site {sitename} install-app hrms
#安装hrms时要在当前命令行窗口运行bench start,然后新建一个窗口安装hrms,安装完成后Ctrl+C停止工作台
18. 设置为生产环境,即用supervisorctl管理所有进程,使用nginx做反向代理。如果安装只是为了做开发,可以跳过这一步。
sudo bench setup production {USERNAME}
sudo nano /etc/supervisor/supervisord.conf
[unix_http_server]
file=var/tmp/supervisord.sock
chmod=0700
chown={USERNAME}:{USERNAME} #在这个位置加上这一行,USERNAME 如frappe:frappe
# 改完后执行
sudo -A systemctl restart supervisor
重要:设置成生产环境后,不用执行bench start进行启动!!
19.下载/安装你需要的其他APP(确认你的网络可以访问GitHub.com)
下载/安装 LOAN / LENDING
bench get-app lending
bench –site {sitename} install-app lending
下载/安装 Education
bench get-app education
bench –site {sitename} install-app education
下载/安装 CHAT
bench get-app chat
bench –site {sitename} install-app chat
下载/安装 界面汉化
bench get-app https://gitee.com/yuzelin/erpnext_chinese.git
bench –site {sitename} install-app erpnext_chinese
下载/安装 Print Designer
bench get-app https://github.com/frappe/print_designer
bench –site {sitename} install-app print_designer
#卸载你不需要的APP
bench –site {sitename} uninstall-app {APPname}
#卸载APP重建文件
bench migrate
20. 查看所需的app是否安装正确,可以用这个命令
bench version
21. 查看一下是否有活动的wokers,如果没有开启生产环境,这一步可以略过。
bench doctor
#正常情况下会显示如下:
—–Checking scheduler status—–
Scheduler disabled for erpnext
Scheduler inactive for erpnext
Workers online: 3
—–erpnext Jobs—–
#如果不成功,可以运行sudo bench setup production {USERNAME}再设置一遍生产环境。
#如需卸载软件,输入dpkg –list列出所有已安装的软件,输入sudo apt-get –purge remove [APPname] 卸载并清除配置文件。
#教程结束