How to Install DHIS2 on your local machine
by Albert Daniel Agoya
1. Create a user in ubuntu for dhis
Username : dhis-youtube
sudo useradd -d /home/dhis-youtube -m dhis-youtube -s /bin/false
2. Set password for user that you created and give permissions
Password: 1234pass
sudo passwd dhis-youtube
sudo usermod -G sudo dhis-youtube
3. Create the configuration directory
sudo mkdir /home/dhis-youtube/config
sudo chown dhis-youtube:dhis-youtube /home/dhis-youtube/config
4. Setting server time zone and locale
sudo dpkg-reconfigure tzdata
locale -a
sudo locale-gen nb_NO.UTF-8
5.PostgreSQL installation
sudo apt-get install postgresql-9.5 postgresql-contrib-9.5 postgresql-9.5-postgis-2.2
6. Create a non-privileged user called dhis by:
sudo -u postgres createuser -SDRP dhis-youtube
7. Enter a secure password at the prompt
1234pass
8. Create a database called dhis2-youtube for user dhis-youtube by invoking
sudo -u postgres createdb -O dhis-youtube dhis2-youtube
9.POSTGIS extension is needed for serveral GIS features to work
sudo -u postgres psql -c "create extension postgis;" dhis2-youtube
10. Configure the PostgreSQL.sql file
Edit the file by invoking the following
sudo nano /etc/postgresql/9.5/main/postgresql.conf
and set the following properties
max_connections = 200
shared_buffers = 3200MB
work_mem = 20MB
maintenance_work_mem = 512MB
effective_cache_size = 8000MB
checkpoint_completion_target = 0.8
synchronous_commit = off
wal_writer_delay = 10000ms
11. Create a file fo postgres configuration
sudo nano /home/dhis-youtube/config/dhis.conf
12. Paste the following
# Hibernate SQL dialect
connection.dialect = org.hibernate.dialect.PostgreSQLDialect
# JDBC driver class
connection.driver_class = org.postgresql.Driver
# JDBC driver connection URL
connection.url = jdbc:postgresql:dhis2-youtube
# Database username
connection.username = dhis-youtube
# Database password
connection.password = 1234pass
# Database schema behavior, can be validate, update, create, create-drop
connection.schema = update
# Encryption password (sensitive)
encryption.password = 1234pass
13. Java Installation
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer
14. Check Java version
java -version
15. You can also ensure that the approriate environment variables are set by isnstalling this package
sudo apt-get install oracle-java8-set-default
16. Tomcat and DHIS2 installation
sudo apt-get install tomcat7-user
cd /home/dhis-youtube/
sudo tomcat7-instance-create tomcat-dhis-youtube
sudo chown -R dhis-youtube:dhis-youtube tomcat-dhis-youtube/
17. Edit the setenv.sh file
sudo nano tomcat-dhis-youtube/bin/setenv.sh
export JAVA_HOME='/usr/lib/jvm/java-8-oracle/'
export JAVA_OPTS='-Xmx7500m -Xms4000m'
export DHIS2_HOME='/home/dhis-youtube/config'
18. Download DHIS.war file from the website
https://www.dhis2.org/downloads
19. Move the war file into tomcat-dhis/webapps/
sudo mv Downloads/dhis.war /home/dhis-youtube/tomcat-dhis-youtube/webapps/Root.war
20. Go into the dhis-youtube directory and Run DHIS2
cd /home/dhis-youtube
sudo tomcat-dhis-youtube/bin/startup.sh
21. To stop DHIS2
sudo tomcat-dhis-youtube/bin/shutdown.sh
Suggested Videos