ERPNext v13 Ubuntu 20.04 安裝教程
步驟如下
1. 準備一台裝好ubuntu20.04的伺服器,本地虛擬機或者VPS皆可,虛擬機的網路要用橋接模式。 Ubuntu 20.04server安裝會順利些,用ssh 工具,如dos 運行命令 ssh root@伺服器ip,putty, secureCRT, Xshell等登錄伺服器。
2. 設定root密碼,在雲伺服器已設過密碼的可跳過此步驟
sudo passwd root
3. 添加使用者,如果使用現有sudo許可權使用者就可以跳過第3、4步。
adduser USERNAME
#用户名USERNAME换成自己计划使用的用户名
4. 將使用者設定sudo權限:
usermod -aG sudo USERNAME
#记得把命令行里的USERNAME改成自己刚设置的用户名
5. 通過ssh登錄root使用者
#虚拟机、騰訊雲需要先設置將埠22開放才能通過ssh連接
vim /etc/ssh/sshd_config
按i,移動游標到以下內容修改:w
#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
# 預發佈軟體源,不建議啟用
# deb Index of /ubuntu/ focal-proposed main restricted universe multiverse
# deb-src Index of /ubuntu/ focal-proposed main restricted universe multiverse
7. 更新並重啟
apt update && apt upgrade -y && shutdown -r now
8. 重新打開SSH連接,並用root登錄,下載node.js
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
#有时候运行完没反应,直接跳回命令輸入,這時候要再運行到出現以下提示
## Installing the NodeSource Node.js 12.x repo...
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
11. 重啟sql
service mysql restart
12. 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
13. 執行下面命令
mysql -u root -p
輸入上面新設置的資料庫root帳號密碼,進入資料庫命令行,並執行下面的語句
USE mysql;
UPDATE user SET plugin=' ' WHERE user ='root';
FLUSH PRIVILEGES;
exit;
13. 【重要】關閉ssh終端,重新以自己"新創建的使用者名"和密碼登錄
15. 安裝yarn
sudo npm install -g yarn
#保险起见,還需要將剛剛的yarn,node,npm添加運行許可權。 sudo chmod +x /usr/bin/node. 默認有運行許可權。 ——Jason Zhang
#配置Yarn的源:
yarn config get registry
查看源, 如果不是淘寶的源就切換為淘寶的源
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"
16. 查看版本,對照一下,這一步不做也行
node -v && npm -v && python3 -V && pip3 -V && yarn -v
17. 安裝bench,即erpnext系統的命令行管理工具,類似windows系統的程式管理器
sudo pip3 install frappe-bench
18. 安裝git,下一步bench init可能會報錯缺少git。
sudo apt install git
19. 使用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
#下面这段是警告说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.
20. 進入bench目錄
cd frappe-bench
21. 新建網站,名字自己取,安裝時會提示輸入資料庫root賬號的密碼, 新網站資料庫及erp系統管理員帳號administator 密碼,其中資料庫root帳號密碼須與上述資料庫安裝時密碼一致,其它密碼自己取 --db-password xxx 也可以命令行參數中直接輸入好密碼,--mariadb-root-password yyyy -- admin-password zzzz
bench new-site mysite
#新建的站点名为mysite
22. 下載erpnext
bench get-app --branch version-13 https://gitee.com/qinyanwan/erpnext
23. 安裝erpnext
bench install-app erpnext
24. 設置為生產環境,即用supervisorctl管理所有進程,使用nginx做反向代理,USERNAME換成第3步新建的帳號,大功告成
sudo bench setup production USERNAME
提示這個 Do you want to continue? [y/N]: y 請輸入 Y,回車
#重要:設置成生產環境后,不用執行bench start進行啟動!!!
25. 安裝完后可查看一下是否有活動的wokers
bench doctor
#正常情况下会显示如下:
-----Checking scheduler status-----
Scheduler disabled for erpnext
Scheduler inactive for erpnext
Workers online: 3
-----erpnext Jobs-----
26. 以上完成後查看一下安裝了哪些app
bench version
正常會顯示以下兩個app
erpnext 13.x.x
frappe 13.x.x
27. 如果是虛似機安裝,需要防火牆入站打開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
28. 阿裡雲伺服器要在安全組裡添加80的入站埠號。
您將需要在ERPNext伺服器上開啟以下埠:
80/tcp and 443/tcp for HTTP and HTTPS respectively
HTTP和HTTPS分別為80/tcp和443/tcp
3306/tcp for MariaDB connection (recommended only if you need remote access to database)
3306/tcp用於MariaDB連接(僅在需要遠端存取資料庫時才建議使用)
143/tcp and 25/tcp for IMAP and STMP respectively
IMAP和STMP分別為143/tcp和25/tcp
22/tcp for SSH (if you have not already enabled OpenSSH in your UFW settings)
SSH 22/tcp (如果尚未在UFW設置中啟用OpenSSH )
8000/tcp for testing your platform before deploying to production
8000/tcp用於在部署到生產環境之前測試平臺
#要一次打开多个端口,可以使用以下命令:
sudo ufw allow 22,25,143,80,443,3306,8000/tcp
sudo ufw允許22,25,143,80,443,3306,8000 / tcp
現在確認防火牆的狀態:
sudo ufw status
附註:安裝ebclocal漢化APP
1. 獲取APP
bench get-app --branch master https://gitee.com/yuzelin/ebclocal
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
sudo apt-get install ttf-wqy-microhei -y
#### Ubuntu20.04 安裝列印wkhtmltopdf 庫
1、先下載適合我們系統的安裝包並進行安裝:
wget "https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-
1/wkhtmltox_0.12.6-1.focal_amd64.deb" -O /tmp/wkhtml.deb
2、下一步進行安裝
sudo dpkg -i /tmp/wkhtml.deb
3、這時可能會顯示缺少依賴的錯誤,以下命令可解決這一問題:
sudo apt -f install
4、現在,我們可以檢查wkhtmltopdf 庫是否正確安裝並確認是否為所需版本:
wkhtmltopdf –version
##### 顯示wkhtmltopdf 0.12.6 (with patched qt)即是正確版本
其他注意:
apt install wkhtmltopdf
##### 這條命令國內阿裡雲源自動安裝版本0.12.5,非patched qt 版本,erpnext 不列印頁面頭部和底部。
如果wkhtmltopdf 庫不是我們需要的版本,應對其進行卸載,命令如下:
sudo apt remove --purge wkhtmltopdf