搭建ERPnext
如果当前登录的是root用户,就请新建一个用于安装ERP的sudo用户。
1
2adduser [frappe-user]
usermod -aG sudo [frappe-user]更新系统并重启系统。
1
apt update && apt upgrade -y && shutdown -r now
使用安装ERP所建好的sudo用户,下载node.js
1
curl -sL https://deb.nodesource.com/setup_16.x | sudo -E bash -
安装操作系统所需的各种依赖包
1
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
将Python的pip源改成国内源,有助于后面安装frappe时提高速度和成功率。
1
2pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/
pip config set install.trusted-host mirrors.aliyun.com接下来开始配置MariaDB,用nano编辑my.cnf文件。
1
sudo nano /etc/mysql/my.cnf
将光标移动到最后空白行,复制以下文本内容,粘贴后注意格式和换行要同下方,ctrl + X返回命令行,保存cy.cnf。
1
2
3
4
5
6
7[mysqld]
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
[mysql]
default-character-set = utf8mb4重启sql
1
sudo service mysql restart
开始mysql的安全配置
1
sudo mysql_secure_installation
第一个输入数据库密码对话框出来的时候,直接敲回车代表没有密码,剩下的按照下面选择:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18# 注:运行结果用 ··· 代替
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! # 看到这句话证明设置成功安装yarn
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26sudo 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 disturl https://npmmirror.com/package/dist && \
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查看版本,对照一下,这一步不做也行.
1
node -v && npm -v && python3 -V && pip3 -V && yarn -v
安装bench,即erpnext系统的命令行管理工具,类似windows系统的程序管理器。
1
sudo -H pip3 install frappe-bench
使用bench命令安装frappe框架。frappe-bench是安装frappe框架的目录名称。
1
bench init --frappe-branch version-14 frappe-bench --frappe-path=https://gitee.com/mirrors/frappe --verbose
再将安装的系统用户分配一下执行权限。
1
chmod -R o+rx /home/[frappe-user]/
进入bench目录
1
cd frappe-bench
新建站点,下面是以erpnext作为站点名称。
1
bench new-site erpnext
设置为生产环境,即用supervisorctl管理所有进程,使用nginx做反向代理。如果安装只是为了做开发,可以跳过这一步。
1
sudo bench setup production {USERNAME}
下载app
1
2
3bench get-app --branch version-14 https://gitee.com/qinyanwan/payments
bench get-app --branch version-14 erpnext https://gitee.com/mirrors/erpnext
bench get-app --branch version-14 https://gitee.com/phipsoft/hrms安装app
1
2
3bench --site {sitename} install-app payments
bench --site {sitename} install-app erpnext
bench --site {sitename} install-app hrms安装完后可查看一下是否有活动的wokers,同样的,如果没开启生产环境,这一步也可以略过。
1
bench doctor
查看所需的app是否安装正确,可以用这个命令
1
bench version
最后解决可能存在PDF打印中文显示乱码所需要的工具
1
wget https://gitee.com/qinyanwan/erpnext/releases/download/v13.29.0/wkhtmltox_0.12.6.1-2.jammy_amd64.deb
1
sudo dpkg -i wkhtmltox_0.12.6.1-2.jammy_amd64.deb
如果安装提示有缺少依赖的错误,执行下面命令。
1
sudo apt -f install
现在,我们可以检查wkhtmltopdf 库是否正确安装并确认是否为所需版本:
1
wkhtmltopdf –version
显示wkhtmltopdf 0.12.6 (with patched qt)即是正确版本
其他
汉化、本地化请登录 https://gitee.com/yuzelin/ 按需安装相关APP。