Ubuntu服务器安装镜像:ubuntu-20.04.4-live-server-amd64.iso,服务器安装为基础安装。
登录服务器创建一个新erpnext用户,为erpnext用户增加sudo权限。
sudo adduser erpnext
sudo usermod -aG sudo erpnext
替换系统软件包的源为国内源。备份/etc/apt/sources.list文件,并更改为下面的内容。
# 默认注释了源码镜像以提高 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
更新系统
sudo apt update
sudo apt upgrade
安装下载node.js,如果因为网络原因安装失败,可以重新运行。(已确认版本node.js 14没有问题)
sudo curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
安装成功后可以看到如下信息:
## Run `sudo apt-get install -y nodejs` to install Node.js 12.x and npm
## You may also need development tools to build native addons:
sudo apt-get install gcc g++ make
## To install the Yarn package manager, run:
curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor | sudo tee /usr/share/keyrings/yarnkey.gpg >/dev/null
echo "deb [signed-by=/usr/share/keyrings/yarnkey.gpg] https://dl.yarnpkg.com/debian stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt-get update && sudo apt-get install yarn
安装需要的依赖包:
sudo apt install -y nodejs mariadb-server-10.3 redis-server python3-pip nginx python3-testresources python2 python3.8-venv
编辑数据库配置文件/etc/mysql/my.cnf,再最后增加下面的内容:
[mysqld]
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
[mysql]
default-character-set = utf8mb4
重启数据库:
sudo service mysql restart
配置数据库安全设置:
sudo 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
设置数据库:
#运行下面的命令(需要输入上面设置的数据库密码)
sudo mysql -u root -p
#在数据库环境下运行下面的语句:
USE mysql;
UPDATE user SET plugin=' ' WHERE user ='root';
FLUSH PRIVILEGES;
exit;
安装yarn
sudo npm install -g yarn
切换到上面创建的erpnext账号运行下面的安装过程
配置yarn的源:
yarn config set registry https://registry.npm.taobao.org
yarn config set sass_binary_site "node-sass Mirror"
yarn config set phantomjs_cdnurl "http://cnpmjs.org/downloads"
yarn config set electron_mirror "electron Mirror"
yarn config set sqlite3_binary_host_mirror "https://foxgis.oss-cn-shanghai.aliyuncs.com/"
yarn config set profiler_binary_host_mirror "node-inspector Mirror"
yarn config set chromedriver_cdnurl "https://cdn.npm.taobao.org/dist/chromedriver"
安装bench,即erpnext系统的命令行管理工具
sudo pip3 install frappe-bench
使用bench命令安装frappe框架,记得把frappe-bench(下方的version-13后面的名字)改成自己想要的名字,这一步时间比较长,代码库已经加了码云地址参数。如果网络超时失败,可重新运行该命令,重新运行之前需使用命令 rm -r frappe-bench
删除之前生成的目录。
bench init --frappe-branch version-13 frappe-bench --frappe-path=https://gitee.com/qinyanwan/frappe
#运行成功后输出:
SUCCESS: Bench frappe-bench initialized
进入bench目录:
cd frappe-bench
新建站点,名字自己取,安装时会提示输入数据库root账号的密码, 新站点数据库及erp系统管理员账号administator 密码,其中数据库root账号密码须与上述数据库安装时密码一致,其它密码自己取 –db-password xxx 也可以命令行参数中直接输入好密码,–mariadb-root-password yyyy –admin-password zzzz
bench new-site mysite
#如果这一步出错需删除~/frappe-bench/sites目录下的mysite文件夹,并进入数据库删除已创建的数据库,然后重复上面的命令。
# show databases
# drop database _xxxxxxxx
下载erpnext (版本号可根据实际情况修改)
bench get-app --branch version-13 https://gitee.com/qinyanwan/erpnext
安装erpnext
bench --site mysite install-app erpnext
获取汉化应用文件:
bench get-app https://gitee.com/yuzelin/erpnext_chinese
安装汉化应用文件
bench --site mysite install-app erpnext_chinese
设置为生产环境,即用supervisorctl管理所有进程,使用nginx做反向代理,USERNAME换成第3步新建的账号,大功告成
sudo bench setup production USERNAME
#可能需要执行一下启动命令
bench start
提示这个 Do you want to continue? [y/N]: y 请输入 Y,回车
重要:设置成生产环境后,不用执行bench start进行启动!!!
安装完后可查看一下是否有活动的wokers:
bench doctor
正常情况下会显示如下:
-----Checking scheduler status-----
Scheduler disabled for erpnext
Scheduler inactive for erpnext
Workers online: 3
浏览器登录主机IP,用户名administrator,密码为上面设置的密码。登录后进入网站设置的向导:
其他:
安装wkhtmltopdf,处理pdf转换
# To Check
#wget "https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-"
sudo apt install wkhtmltopdf
#如果pdf转换出现乱码,安装下面的字体
sudo apt-get install ttf-wqy-zenhei -y
sudo apt-get install ttf-wqy-microhei -y