Support #951
Updated by Daniel Curtis about 5 years ago
{{>toc}}
This is a guide on installing a self-hosted OFBiz instance on FreeBSD 12.2-RELEASE.
h2. Prepare the Environment
* Make sure the system is up to date:
<pre>
pkg update && pkg upgrade
</pre>
* Add ofbiz user:
<pre>
pw add user -n ofbiz -m -s /bin/sh -c "OFBiz"
</pre>
* Install the dependencies:
<pre>
pkg install openjdk8 git gradle
</pre>
h3. Configure PostgreSQL
* Install PostgreSQL:
<pre>
pkg install postgresql-jdbc postgresql96-server postgresql96-client postgresql96-contrib
</pre>
* Initialize, start, and enable postgresql at boot:
<pre>
sysrc postgresql_enable="YES"
service postgresql initdb
service postgresql start
</pre>
* Log in to postgresql user account and connect to database:
<pre>
su - postgres
psql -d template1
</pre>
#* Create a user:
<pre>
CREATE USER ofbiz WITH PASSWORD 'SuperSecretPassword' CREATEDB;
</pre>
#* Create the databases & grant all privileges on database
<pre>
CREATE DATABASE ofbizdb OWNER ofbiz encoding='UTF8';
CREATE DATABASE ofbizolapdb OWNER ofbiz encoding='UTF8';
CREATE DATABASE ofbiztenantdb OWNER ofbiz encoding='UTF8';
</pre>
* Quit the database session
<pre>
\q
exit
</pre>
h2. Install OFBiz
* Download and compile ofbiz:
<pre>
su - ofbiz
git clone -b release18.12 https://github.com/apache/ofbiz-framework
cd ofbiz-framework
</pre>
* Edit the *entityengine.xml* file:
<pre>
vi framework/entity/config/entityengine.xml
</pre>
#* And modify the @group-map@ section:
<pre><code class="xml">
<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.apache.ofbiz" datasource-name="localpostgres"/>
<group-map group-name="org.apache.ofbiz.olap" datasource-name="localpostgresolap"/>
<group-map group-name="org.apache.ofbiz.tenant" datasource-name="localpostgrestenant"/>
</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.apache.ofbiz" datasource-name="localpostgres"/>
<group-map group-name="org.apache.ofbiz.olap" datasource-name="localpostgresolap"/>
<group-map group-name="org.apache.ofbiz.tenant" datasource-name="localpostgrestenant"/>
</delegator>
<delegator name="test" entity-model-reader="main" entity-group-reader="main" entity-eca-reader="main">
<group-map group-name="org.apache.ofbiz" datasource-name="localpostgres"/>
<group-map group-name="org.apache.ofbiz.olap" datasource-name="localpostgresolap"/>
<group-map group-name="org.apache.ofbiz.tenant" datasource-name="localpostgrestenant"/>
</delegator>
</code></pre>
#* Also modify the @datasource@ section:
<pre><code class="xml">
<datasource name="localpostgres"
helper-class="org.apache.ofbiz.entity.datasource.GenericHelperDAO"
schema-name="public"
field-type-name="postgres"
check-on-start="true"
add-missing-on-start="true"
use-fk-initially-deferred="false"
alias-view-columns="false"
join-style="ansi"
use-binary-type-for-blob="true"
use-order-by-nulls="true"
result-fetch-size="50">
<read-data reader-name="tenant"/>
<read-data reader-name="seed"/>
<read-data reader-name="seed-initial"/>
<read-data reader-name="demo"/>
<read-data reader-name="ext"/>
<read-data reader-name="ext-test"/>
<read-data reader-name="ext-demo"/>
<inline-jdbc
jdbc-driver="org.postgresql.Driver"
jdbc-uri="jdbc:postgresql://127.0.0.1:5433/ofbizdb"
jdbc-username="ofbiz"
jdbc-password="SuperSecretPassword"
isolation-level="ReadCommitted"
pool-minsize="2"
pool-maxsize="250"
time-between-eviction-runs-millis="600000"/>
</datasource>
<datasource name="localpostgresolap"
helper-class="org.apache.ofbiz.entity.datasource.GenericHelperDAO"
schema-name="public"
field-type-name="postgres"
check-on-start="true"
add-missing-on-start="true"
use-fk-initially-deferred="false"
alias-view-columns="false"
join-style="ansi"
result-fetch-size="50"
use-binary-type-for-blob="true"
use-order-by-nulls="true">
<read-data reader-name="tenant"/>
<read-data reader-name="seed"/>
<read-data reader-name="seed-initial"/>
<read-data reader-name="demo"/>
<read-data reader-name="ext"/>
<read-data reader-name="ext-test"/>
<read-data reader-name="ext-demo"/>
<inline-jdbc
jdbc-driver="org.postgresql.Driver"
jdbc-uri="jdbc:postgresql://127.0.0.1:5433/ofbizolapdb"
jdbc-username="ofbiz"
jdbc-password="SuperSecretPassword"
isolation-level="ReadCommitted"
pool-minsize="2"
pool-maxsize="250"
time-between-eviction-runs-millis="600000"/>
</datasource>
<datasource name="localpostgrestenant"
helper-class="org.apache.ofbiz.entity.datasource.GenericHelperDAO"
schema-name="public"
field-type-name="postgres"
check-on-start="true"
add-missing-on-start="true"
use-fk-initially-deferred="false"
alias-view-columns="false"
join-style="ansi"
result-fetch-size="50"
use-binary-type-for-blob="true"
use-order-by-nulls="true">
<read-data reader-name="tenant"/>
<read-data reader-name="seed"/>
<read-data reader-name="seed-initial"/>
<read-data reader-name="demo"/>
<read-data reader-name="ext"/>
<read-data reader-name="ext-test"/>
<read-data reader-name="ext-demo"/>
<inline-jdbc
jdbc-driver="org.postgresql.Driver"
jdbc-uri="jdbc:postgresql://127.0.0.1:5433/ofbiztenantdb"
jdbc-username="ofbiz"
jdbc-password="SuperSecretPassword"
isolation-level="ReadCommitted"
pool-minsize="2"
pool-maxsize="250"
time-between-eviction-runs-millis="600000"/>
</datasource></code></pre>
* Edit the *build.gradle* file:
<pre>
vi build.gradle
</pre>
#* And insert the postgres jdbc to the end of the compile dependencies:
<pre>
dependencies {
// ofbiz compile libs
...
compile 'org.postgresql:postgresql:42.2.18'
}
</pre>
* Compile ofbiz:
<pre>
./gradlew cleanAll loadAll
</pre>
h2. Resources
* https://github.com/apache/ofbiz-framework
* https://github.com/apache/ofbiz-plugins
* https://cwiki.apache.org/confluence/display/OFBIZ/Setup+OFBiz+version+16.11.02+with+PostgreSQL+on+Windows