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/false2. Set password for user that you created and give permissions
Password: 1234pass
sudo passwd dhis-youtubesudo usermod -G sudo dhis-youtube3. Create the configuration directory
sudo mkdir /home/dhis-youtube/configsudo chown dhis-youtube:dhis-youtube /home/dhis-youtube/config4. Setting server time zone and locale
sudo dpkg-reconfigure tzdatalocale -asudo locale-gen nb_NO.UTF-85.PostgreSQL installation
sudo apt-get install postgresql-9.5 postgresql-contrib-9.5 postgresql-9.5-postgis-2.26. Create a non-privileged user called dhis by:
sudo -u postgres createuser -SDRP dhis-youtube7. 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-youtube9.POSTGIS extension is needed for serveral GIS features to work
sudo -u postgres psql -c "create extension postgis;" dhis2-youtube10. Configure the PostgreSQL.sql file
Edit the file by invoking the following
sudo nano /etc/postgresql/9.5/main/postgresql.confand 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.conf12. 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/javasudo apt-get updatesudo apt-get install oracle-java8-installer14. Check Java version
java -version15. You can also ensure that the approriate environment variables are set by isnstalling this package
sudo apt-get install oracle-java8-set-default16. Tomcat and DHIS2 installation
sudo apt-get install tomcat7-usercd /home/dhis-youtube/sudo tomcat7-instance-create tomcat-dhis-youtubesudo chown -R dhis-youtube:dhis-youtube tomcat-dhis-youtube/17. Edit the setenv.sh file
sudo nano tomcat-dhis-youtube/bin/setenv.shexport 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.war20. Go into the dhis-youtube directory and Run DHIS2
cd /home/dhis-youtubesudo tomcat-dhis-youtube/bin/startup.sh21. To stop DHIS2
sudo tomcat-dhis-youtube/bin/shutdown.shSuggested Videos