Wednesday, August 8, 2018

DHIS2 Local Installation Guide for Microsoft Windows 10

DHIS2 Local Installation Guide for Microsoft Windows


DHIS2 runs on all platforms for which there exists a Java Runtime Environment version 8 or higher, which includes most popular operating systems such as Windows, Linux and Mac. DHIS2 runs on the PostgreSQL database system. DHIS2 is packaged as a standard Java Web Archive (WAR-file) and thus runs on any Servlet containers such as Tomcat and Jetty.

The DHIS2 team recommends Ubuntu 16.04 LTS operating system, PostgreSQL database system and Tomcat Servlet container as the preferred environment for server installations.

In this blog I am trying to guide guide you for setting up the above technology stack in Windows 10 Platform. It should however be read as a guide for getting up and running and not as an exhaustive documentation for the mentioned environment. We refer to the official Windows, PostgreSQL and Tomcat 8 documentation for in-depth reading.

Hardware requirement

DHIS2 is a database intensive application and requires that your server has an appropriate amount of RAM, number of CPU cores and a fast disk. These recommendations should be considered as rules-of-thumb and not exact measures. DHIS2 scales linearly on the amount of RAM and number of CPU cores so the more you can afford, the better the application will perform. 

For desktop installation with a blank database the following hardware requirement should be meet. To run Windows OS and services it nearly require 2GB of RAM. So computer should have at least 6 GB of and have at least 4 CPU cores; 6 core will be good.

Disk: Ideally use an SSD. Otherwise use a 7200 rpm disk. Minimum read speed is 150 Mb/s, 200 Mb/s is good, 350 Mb/s or better is ideal. In terms of disk space, at least 60 GB is reccomended, but will depend entirely on the amount of data which is contained in the data value tables. Analytics tables require a significant amount of disk space. Plan ahead and ensure that your server can be upgraded with more disk space as it becomes needed.

Software requirements

Later DHIS2.30 versions require the following software versions to operate.

Oracle Java JRE/JDK version 8 or later.
PostgreSQL database version 10 or later.
PostGIS database extension version 2.4 or later.
Tomcat servlet container version 8 or later.

Install all software as administrator.

Creating the configuration directory

Start by creating a suitable directory for the DHIS2 configuration files. This directory will also be used for apps, files and log files. An example directory could be: 'd:\dhis2\config'. Use the drive which have more space and preferably not on the Widows drive.

DHIS2 will look for an environment variable called DHIS2_HOME to locate the DHIS2 configuration directory. This directory will be referred to as DHIS2_HOME in this installation guide. 

Install Oracle Java 8 

Go to https://www.java.com/en/download/ and click on 'Free Java Download' agree the licence agreement and install Java 8 (JDK or JRE). JRE is sufficient.

Install Tomcat 8

Install Tomcat 8 “32-bit/64-bit Windows Service Installer”(it is VERY important that you install only the service installer - not the 32 bit or 64bit windows zip): https://tomcat.apache.org/download-80.cgi#8.5.32

***DO NOT start Tomcat at the end of installation***; if you did accidentally, then please stop the service.

Install PostgreSQL 10

Install PostgreSQL 10 from https://www.openscg.com/bigsql/postgresql/installers.jsp/

Note down and remember the postgres password you created and installation port (default 5432). Do no install on C: or windows drive, try to install on D:\ or the drive have good amount of space. 

Install Pgadmin 4 

Install PGADMIN4 form https://ftp.postgresql.org/pub/pgadmin/pgadmin4/v3.1/windows/pgadmin4-3.1-x86.exe. This a graphical database administration package.

Define the environment variable

My Computer (Right Click) → Properties → Advanced system settings → Environmental Variables



Under “System Variables” click “New” to add following:
Variable Name: DHIS2_HOME
      Value: D:\DHIS2\CONFIG
Variable Name: JAVA_OPTS
      Value: -Xms512m -Xmx2048m -XX:PermSize=256m -XX:MaxPermSize=768m
Make sure “Path” variable include the path to JDK’s “bin” folders address (i.e. C:\Program Files\Java\jdk1.8.0_45\bin)



Create database

Open “PgAdmin 4” and connect with the password you gave during installation.
Right click databases and create a new database “dhis2” set Owner as “postgres”



Create DHIS2 Configuration file


DHIS using configuration file, is called, "dhis.conf" and resides in the DHIS2 home folder given in the environmental variables. We create a folder  'd:\dhis2\config' folder. Create a text "dhis.conf" in the above folder. Make sure the configuration files details reflect the details of the database created.

dhis.conf file content will be:

# Hibernate SQL dialect
connection.dialect = org.hibernate.dialect.PostgreSQLDialect
# JDBC driver class
connection.driver_class = org.postgresql.Driver
# Database connection URL
jdbc:postgresql://localhost:5432/dhis2_test
# Database username
connection.username = postgres
# Database password
connection.password = Postgres1#
# Database schema behavior, can be validate, update, create, create-drop
connection.schema = update
# Encryption password (sensitive)
encryption.password = xxxxxxxx

Note that encryption password should long and combination of multiple characters. Pleas kept it properly and if lost might not decrypt data of individual records.

Download DHIS2 war file 

Download the latest DHIS2 war file dhis.war (https://www.dhis2.org/downloads) and copy it in to “webapps” folder of the Tomcat installation (i.e. C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps).

Run Tomcat and DHIS2

Run Tomcat 8 service to deploy the war file. Once the deployment is complete access DHIS2 using the web browser: http://localhost:8080/dhis/.

    Username: admin
    Password: district