Deploy DHIS2 on Alibaba Cloud ECS Instance

By Erick Otenyo, Alibaba Cloud Tech Share Author. Tech Share is Alibaba Cloud’s incentive program to encourage the sharing of technical knowledge and best practices within the cloud community.

DHIS2 is a tool for collection, validation, analysis, and presentation of aggregate and patient-based statistical data, tailored to integrated health information management activities. It is a generic tool rather than a pre-configured database application, with an open meta-data model and a flexible user interface that allows the user to design the contents of a specific information system without the need for programming.

The DHIS2 database is designed ground-up with flexibility in mind. Data structures such as data elements, organisation units, forms and user roles can be defined completely freely through the application user interface. This makes it possible to adapt the system to a multitude of locale contexts and use cases that require routine data capture and analysis. This has allowed for DHIS2 to serve as management system in different domains such as logistics, labs and finance.

DHIS2 is an open source software under the BSD licence and thus can be obtained freely and run on any platform with a Java Runtime Environment installed.

The following are the key features and purpose of DHIS2

  • DHIS2 provides a comprehensive data management solution based on data warehousing principles and a modular structure which can easily be customised to the different requirements of a management information system, supporting analysis at different levels of the organisational hierarchy.
  • Customisation and local adaptation through the user interface. Setting up and configuring DHIS2 doesn not require programming.
  • Provides data entry tools which can either be in the form of standard lists or tables, or can be customised to replicate paper forms.
  • Flexible and dynamic data analysis in the analytics modules (i.e. GIS Maps, PivotTables,Data Visualizer, Event reports, etc).
  • Easy to use user-interfaces for metadata management e.g. for adding/editing datasets or health facilities. No programming needed to set up the system in a new setting
  • A user-specific dashboard for quick access to the relevant monitoring and evaluation tools including indicator charts and links to favourite reports, maps and other key resources in the system.

A typical informaton cycle in a DHIS2 system icludes:

  1. Data collection
  2. Data quality checks and validation
  3. Data access at multiple security levels
  4. Reporting
  5. Visualizing data with graphs, pivot tables and maps
  6. Comparison of data across time, different organisation units (facilites in health)
  7. Visualizing trends in a time series analysis

In this tutorial, we will be covering on how to get DHIS2 up and running on an Alibaba Cloud Elastic Compute Service (ECS) Ubuntu 16.04 instance.


Before we deploy our DHIS2 instance, we need to fulfill the following requirements. We need to set up an Alibaba Cloud Elastic Compute Service (ECS) Linux server (Ubuntu 16.04) with atleast 4GB of RAM and basic configurations. You should also allocate administrator (sudo) privileges to a non-root user.

You can refer to this guide for setting up your Alibaba Cloud ECS instance. If you don’t have an Alibaba Cloud account, you can sign up for free and enjoy $300 worth in Free Trial.

Deploying DHIS2 on Ubuntu 16.04 ECS Instance

To deploy DHIS2 on our server, we will first need to install a few requirements and configure the Java Runtime Environment neccessary for DHIS2 to run.

We will need to install a Postgres/PostGIS database and thereafter install Java and setup the configurations.

Step 1: Setting Server Time Zone

It may be important to match the server timezone with the location which the DHIS2 server will be covering. The default time zone on the ECS instance may not correspond to the time zone of your DHIS2 location. To reconfigure the timezone, invoke the command below and follow the instructions displayed:

Step 2: Creating an Ubuntu User to Run DHIS2

The DHIS2 server should not be run as a privileged user such as root. Therefore create a new dedicated user for running DHIS by invoking:

Then set the password for the account by invoking:

Make sure you set a strong password

Step 3: Creating the Configuration Directory

Create a suitable directory for the DHIS2 configuration files that will also be used for apps in DHIS2, files and log files

Set ownership of the directory to ‘dhis’ user created above

Step 4: PostgreSQL Installation and Tuning

Install PostgreSQL and the PostGIS extension by invoking:

Create a non-privileged PostgreSQL user called ‘dhis’ by invoking:

Give a password for the new PostgreSQL user when prompted.

Create a database that will be used by the DHIS2 instance by invoking:

The PostGIS extension is needed for several GIS/mapping features to work. Create the PostGIS extension by invoking:

PostgreSQL performance tuning is necesarry to achieve a high performing system in a production environment. Note this is not neccessary in terms of getting DHIS2 to run.

Open the postgresql.conf file for editing:

Set the following properties:

For an indepth explanation of the above properties, please refer the DHIS2 docs

Step 5: Creating DHIS2 Configuration File

The database connection information is provided to DHIS2 through a configuration file called dhis.conf. Create this file and save it in the configuration directory we created in Step 3:

Insert following lines to the file (update PostgreSQL dhis user password according what you set above):

Step 6: Java Installation

Oracle Java will need to be installed manually. Create a directory to install Java:

Next we need to download oracle java from the Java download page.

Obtain the correct download link with 'Linux x64' from the above link and replace http://oracle-java-download-link in the command below with that link. It should look something like

After downloading, untar by invoking the following:

Step 7: Tomcat Installation

To install the Tomcat servlet container we will utilize the Tomcat user package. This lets us easily create a new Tomcat instance. Install the package by invoking:

To create a Tomcat instance for DHIS2 move to the dhis folder created earlier:

Create Tomcat instance:

Set ownership of the created folder to dhis user


Add the following lines to the bottom of the file:

Please note that jre1.8.0_191 directory as below may change according to oracle java version downloaded.

Step 8: DHIS Installation

The next step is to now download the DHIS2 WAR file and place it into the webapps directory of Tomcat.

You can download the DHIS2 version 2.30 WAR release as below (replace 2.30 with your preferred version if necessary):

Move the WAR file into the Tomcat webapps directory. We want to call the WAR file ROOT.war in order to make it available at localhost directly without a context path:

DHIS2 should never be run as a privileged user, so edit the to use the dhis user we created earlier:

Replace everything in the file with the following lines:

Step 10: Running DHIS2

DHIS2 can now be started by invoking:

To monitor the behavior of Tomcat, the log is the primary source of information. The log can be viewed with the following command:

Assuming that the WAR file is called ROOT.war, you can now access your DHIS2 instance at:


The Default login details are:

DHIS2 can be stopped by invoking:

Step 11: Starting DHIS2 at Server Startup

In certain situations the server might reboot unexpectedly. It is preferable to have Tomcat start automatically when the server starts. To achieve that the first step is to create init scripts.

Create init scripts:

Enter the following lines:

Move the script to the init script directory and make it executable by invoking:

Next make sure the tomcat init script will be invoked during system startup and shutdown:

Tomcat will now be started at system startup and stopped at system shutdown. If you later need to revert this you can replace defaults with remove and invoke the above commands again


Hooray ! If you were able to follow this tutorial up to this point, your DHIS2 instance should be up and running on your Alibaba Cloud Elastic Compute Service (ECS) Instance. We have done a basic setup to get us started with our DHIS2 server, but you might need further customization for DHIS2 to work as per your use case, mainly from the admin user interface. For that and more, you can refer to the official documentantion of DHIS2, which covers all the DHIS2 platform instructions in detail.


Follow me to keep abreast with the latest technology news, industry insights, and developer trends.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store