安裝apache-ofbiz

作業系統: Centos 6.5
安裝項目: Apache-ofbiz (企業會計,管,銷,存,線上購物,人事...免費軟體)
安裝路徑:可以放在任何檔案中,假設是放在 之中


1. 建立資料庫
# mysql -u root -p
# Mysql> create database ofbiz;
# mysql> create user ofbiz;
# mysql> grant all privileges on ofbiz.* to 'ofbiz'@'localhost' identified by
'xxxxxxxx';
# Mysql> create database ofbizolap;
# mysql> create user ofbizolap;
# mysql> grant all privileges on ofbizolap.* to 'ofbizolap'@'localhost'
identified by 'xxxxxxxx';
# Mysql> create database ofbiztenant;
# mysql> create user ofbiztenant;
# mysql> grant all privileges on ofbiztenant.* to 'ofbiztenant'@'localhost'
identified by 'xxxxxxxx';
# mysql> exit
(註:xxxxxxxx是自己的密碼)

2. 在/var/www/html檔案中建立一個ofbiz資料夾;
下載ofbiznightly branch 13.07後放入 /var/www/html/ofibiz 中

3. 修改 entityengine.xml(路徑 /var/www/html/ofibiz/framework/entity/config/entityengine.xml)
a. 修改 delegator name;將相關部份設定為
<delegator name="default" entity-model-reader="main" entity-group-reader="main" entity-eca-reader="main" distributed-cache-clear-enabled="false">
<group-map group-name="org.ofbiz" datasource-name="localmysql"/>
<group-map group-name="org.ofbiz.olap" datasource-name="localmysqlolap"/>
<group-map group-name="org.ofbiz.tenant" datasource-name="localmysqltenant"/>
</delegator>
<delegator name="default-no-eca" entity-model-reader="main" entity-group-reader="main" entity-eca-reader="main" entity-eca-enabled="false" distributed-cache-clear-enabled="false">
<group-map group-name="org.ofbiz" datasource-name="localmysql"/>
<group-map group-name="org.ofbiz.olap" datasource-name="localmysqlolap"/>
<group-map group-name="org.ofbiz.tenant" datasource-name="localmysqltenant"/>
</delegator>
<!-- be sure that your default delegator (or the one you use) uses the same datasource for test. You must run "ant load-demo" before running "ant run-tests" -->
<delegator name="test" entity-model-reader="main" entity-group-reader="main" entity-eca-reader="main">
<group-map group-name="org.ofbiz" datasource-name="localmysql"/>
<group-map group-name="org.ofbiz.olap" datasource-name="localmysqlolap"/>
<group-map group-name="org.ofbiz.tenant" datasource-name="localmysqltenant"/> </delegator>

b. 修改<datasource name="localmysql", <datasource name="localmysqlolap",
<datasource name="localmysqltenant"中的
(1) username & password
(2) character-set="utf8" collate="utf8_general_ci"
(3) 刪掉 table-type="InnoDB"
(database default Mysiam, if it is Innodb, chagnge table-type="InnoDB"
to table-engine="InnoDB" )
(4) 修改中文亂碼,
i)
jdbc-uri="jdbc:mysql://127.0.0.1/ofbiz?autoReconnect=true"
改為
jdbc-uri="jdbc:mysql://127.0.0.1/ofbiz?autoReconnect=true&amp;useUnicode=true&amp;characterEncoding=UTF-8"

jdbc-uri="jdbc:mysql://127.0.0.1/ofbizolap?autoReconnect=true"
改為
jdbc-uri="jdbc:mysql://127.0.0.1/ofbizolap?autoReconnect=true&amp;useUnicode=true&amp;characterEncoding=UTF-8"

jdbc-uri="jdbc:mysql://127.0.0.1/ofbiztenant?autoReconnect=true"
改為
jdbc-uri="jdbc:mysql://127.0.0.1/ofbiztenant?autoReconnect=true&amp;useUnicode=true&amp;characterEncoding=UTF-8"

ii) 修改startofbiz.bat (路徑opt/ofbiz/tools/startofbiz.bat) 檔案中
"%JAVA_HOME%\bin\java" -Xms128M -Xmx512M -XX:MaxPermSize=128m -jar ofbiz.jar
改為
"%JAVA_HOME%\bin\java" -Xms128M -Xmx512M -XX:MaxPermSize=128m -Dfile.encoding=UTF-8 -jar ofbiz.jar

4. 下載 mysql-connector-java-5.1.29 將其中的mysql-connector-java-5.1.29-bin.jar放
入/var/www/html/ofibiz/framework/entity/lib/jdbc之中

5. 安裝Apache OfBiz
# cd /var/www/html/ofbiz/
# ./ant
# ./ant load-demo
# ./ant load-extseed
# ./ant start

7. 查看網址:

https://www

.你的網址:8443/catalog
登入Username: admin
密碼: ofbiz

購物車

http://www

.你的網址:8080/ecommerce

8. 若要重新安裝先執行:
# ./ant stop
# ./ant clean
將mysql-connector-java-5.1.29 將其中的mysql-connector-java-5.1.29-bin.jar放
入opt/ofibiz/framework/entity/lib/jdbc之中,再重新開始。

9. 重開機自動啟動
a. 改為後台啟動程序:
修改 startofbiz.sh (路徑 /var/www/html/ofbiz/tools/startofbiz.sh)
(cd "$OFBIZ_HOME" && exec "$JAVA" $VMARGS -jar ofbiz.jar "$@")
改為
cd "$OFBIZ_HOME" && $JAVA $VMARGS -jar ofbiz.jar $* >>$OFBIZ_LOG 2>>$OFBIZ_LOG

b. 在 etc/rc.local 中加入這一行
/var/www/html/ofbiz/tools/startofbiz.sh

c. 若是不用上述方法,在etc/init.d中建立一個ofbiz的sh檔,再將下列script貼入
#!/bin/sh
# chkconfig: - 80 10
# description: ofbiz server

export OFBIZ_HOME=/var/www/html/ofbiz
start_ofbiz="$OFBIZ_HOME/tools/startofbiz.sh start"
stop_ofbiz="$OFBIZ_HOME/tools/stopofbiz.sh stop"

# Source function library
. /etc/rc.d/init.d/functions

start() {
echo -n "Starting ofbiz: "
${start_ofbiz} &
echo "done."
}
stop() {
echo -n "Shutting down ofbiz: "
${stop_ofbiz}
echo "done."
}

case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
sleep 10
start
;;
*)
echo "Usage: $0 {start|stop|restart}"
esac

exit 0

然後

# chkconfig --add ofbiz
# chkconfig ofbiz on
.
# cd /etc/init.d/
# chmod 777 ofbiz
然後測試啟動服務:
# /etc/init.d/ofbiz start
停止服務
# /etc/init.d/ofbiz stop