在Ubuntu Server 18.04版本安裝ERPNEXT(100%成功)

之前參考過許多手冊和文檔安裝開源的ERP,都非常麻煩,而且經常遇到各種問題,經過多次實踐,結合了幾篇國內文章與國外 的文章,編寫此教程,相信可一次成功。

建議硬件配置

CPU:2核

內存:2G

硬盤:10G

更新包源爲國內源

備份原有軟件源文件

cp /etc/apt/sources.list /etc/apt/sources.list.bak

更新源列表

nano /etc/apt/sources.list

內容


deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb [arch=arm64,ppc64el,amd64] http://mirrors.tuna.tsinghua.edu.cn/mariadb/repo/10.4/ubuntu bionic main

系統更新及軟件升級

sudo apt-get update && sudo apt-get upgrade

安裝python以及檢查python的版本號

sudo apt install python-minimal –y

python -V

安裝ERPNext軟件所依賴的軟件包

sudo apt -y install git build-essential python-setuptools python-dev libffi-dev libssl-dev

安裝python的pip包

下載安裝包,並運行更新

wget https://bootstrap.pypa.io/get-pip.py

sudo python get-pip.py

檢查是否爲最新版,如果不爲最新版,則進行升級

sudo pip install --upgrade pip setuptools

安裝ansible的python框架包

sudo pip install ansible

(在運行中可能存在連接失敗的情況,多運行兩次即可,如果一直不行,可以開啓自己的移動號碼的手機熱點,再進行安裝,如果依舊不行,則需要更改國內源,如sudo pip install ansible -i https://pypi.tuna.tsinghua.edu.cn/simple)

安裝yarn構建管理工具

先安裝curl軟件

sudo apt -y install curl

加入apt中yarn的安裝源

curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add –

echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list

成功後,安裝yarn構建管理工具

sudo apt -y update && sudo apt -y install yarn

安裝MariaDb數據庫

由於國外源較慢,因爲採用清華大學鏡像以下進行Mariadb的安裝

加入清華源

sudo apt-get install software-properties-common

sudo apt-key adv --fetch-keys 'https://mariadb.org/mariadb_release_signing_key.asc'

sudo add-apt-repository 'deb [arch=amd64,arm64,ppc64el] http://mirrors.tuna.tsinghua.edu.cn/mariadb/repo/10.4/ubuntu bionic main'

安裝數據庫

sudo apt update

sudo apt install mariadb-server libmysqlclient-dev

配置數據庫配置文件

sudo nano /etc/mysql/my.cnf

在my.cnf中配置相應的數據庫啓動參數,主要是設置innodb的文件類型以及字符編碼集

[mysqld]

innodb-file-format=barracuda

innodb-file-per-table=1

innodb-large-prefix=1

character-set-client-handshake = FALSE

character-set-server = utf8mb4

collation-server = utf8mb4_unicode_ci



[mysql]

default-character-set = utf8mb4

    重啓Maraidb服務,並配置數據庫啓動時自動啓動

sudo systemctl restart mariadb

sudo systemctl enable mariadb

    設置數據庫的安全設置

sudo mysql_secure_installation

    首先確認是否作用unix_socket連接,選擇N

    包括設置root的密碼以及以下設置

  • Remove anonymous users? Y
  • Disallow root login remotely? N
  • Remove test database and access to it? y
  • Reload privilege tables now? Y

安裝Nginx,Node.js以及Redis

下載Node.js的源

sudo curl --silent --location https://deb.nodesource.com/setup_10.x | sudo bash -

    成功後,進行相關服務的安裝和運行,並將相關的服務加入到啓動項   

sudo apt -y install nginx nodejs redis-server

sudo systemctl start nginx

sudo systemctl enable nginx

sudo systemctl start redis-server

sudo systemctl enable redis-server

安裝wkhtmltopdf和相關字體,用於網頁轉PDF和圖片

sudo apt -y install libxrender1 libxext6 xfonts-75dpi xfonts-base

sudo apt-get install xvfb

sudo apt install wkhtmltopdf

sudo mv /usr/bin/wkhtmltopdf /usr/bin/wkhtmltopdf.sh

sudo mv /usr/bin/wkhtmltoimage /usr/bin/wkhtmltoimage.sh

echo 'exec xvfb-run -a -s "-screen 0 640x480x16" wkhtmltopdf.sh "$@"' | sudo tee /usr/local/bin/wkhtmltopdf >/dev/null && sudo chmod a+x /usr/local/bin/wkhtmltopdf

echo 'exec xvfb-run -a -s "-screen 0 640x480x16" wkhtmltoimage.sh "$@"' | sudo tee /usr/local/bin/wkhtmltoimage >/dev/null && sudo chmod a+x /usr/local/bin/wkhtmltoimage

檢查版本

wkhtmltopdf -V

檢查是否可以運行

wkhtmltopdf http://www.baidu.com output.pdf

安裝和創建虛擬的python運行環境

首先,創建erpnext目錄

mkdir erpnext

cd erpnext/

安裝虛擬環境

sudo apt install virtualenv

在erpnext目錄下創建erpnext運行環境

virtualenv .

(注意命令中包括.這個字符,表示當前目錄)

有可能安裝連接超時失敗,因此可以參考如下操作

mkdir ~/.pip

nano ~/.pip/pip.conf

內容如下:

[global]

index-url = http://mirrors.aliyun.com/pypi/simple/



[install]

trusted-host=mirrors.aliyun.com

保存後再執行virtualenv .

激活當前的虛擬運行環境

source ./bin/activate

安裝bench工具

此文件用於管理多站點,以運行erpnext應用

git clone https://github.com/frappe/bench bench-repo

sudo pip install -e bench-repo

初始化bench

bench init --frappe-branch master --frappe-path https://github.com/frappe/frappe.git frappe-bench

進入frapper-bench目錄

cd frappe-bench/

獲取erpnext應用程序

bench get-app --branch master erpnext https://github.com/frappe/erpnext.git

創建網站

bench new-site testsite

注意你可根據自己的域名,進行變更testsite

在上一步新建的站點上安裝erpnext應用

bench --site testsite install-app erpnext

啓動應用,並進行測試

bench start

如果出現錯誤,找不到werkzeug類庫

env/bin/pip3.6 install werkzeug==0.9

其中,如果沒有外網的指定域名,無法訪問剛纔建的域名站點,可以在自己的電腦上更改hosts文件,加入域名對應的IP即可以訪問。

c:\windows\system32\drivers\etc\hosts

在更改此文件內容時,需要更新此文件安全屬性,將此文件的可寫可讀的權限設置給當前登陸的用戶

打開文件根據自己的IP加入對應關係

192.168.56.104  testsite

最後,打開您的web瀏覽器,打開服務器IP地址並輸入8000端口號http://testsite:8000,您將看到ERPNext登錄屏幕。在這裏,你必須按照你創建新網站時設置的用戶名“管理員”和密碼登錄。

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章