1. Linux
1.1. Installation
-
Enter the following commands at a Command Line.
# Create new user. sudo useradd -d /home/dhis -m dhis -s /bin/false sudo passwd dhis # Enter the new password (level 1 + level 2). # Check the new password (level 1 + level 2). # Create configuration directory. sudo mkdir /home/dhis/config sudo chown dhis:dhis /home/dhis/config # PostgreSQL installation. # See https://wiki.postgresql.org/wiki/Apt sudo apt-get --yes install lsb-release sudo smru setup gnupg # Install and configure gnupg. curl --insecure https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/apt.postgresql.org.gpg > /dev/null sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list' sudo apt-get update sudo apt-get install postgresql-12 postgresql-12-postgis-3 # Create a non-privileged user. sudo -u postgres createuser -SDRP dhis # Enter the new password (level 2 + level 3). # Check the new password (level 2 + level 3). # Create a database. sudo -u postgres createdb -O dhis dhis2 sudo -u postgres psql --list sudo -u postgres psql -c "create extension postgis;" dhis2 # List database extensions. # sudo -u dhis psql dhis2 # \dx # \q # Java installation. sudo apt-get install openjdk-11-jdk java -version
1.2. Configuration
-
Enter the following commands at a Command Line.
sudo touch /home/dhis/config/dhis.conf sudo chmod 600 /home/dhis/config/dhis.conf sudo chown dhis:dhis /home/dhis/config/dhis.conf
-
Add the following contents to the /home/dhis/config/dhis.conf file.
-
Replace the asterisks by the actual password (level 2 + level 3).
# ---------------------------------------------------------------------- # Database connection # ---------------------------------------------------------------------- # JDBC driver class connection.driver_class = org.postgresql.Driver # Database connection URL connection.url = jdbc:postgresql:dhis2 # Database username connection.username = dhis # Database password connection.password = ******** # ---------------------------------------------------------------------- # Server # ---------------------------------------------------------------------- # Enable secure settings if deployed on HTTPS, default 'off', can be 'on' # server.https = on # Server base URL # server.base.url = https://server.com
1.3. Tomcat
-
Enter the following commands at a Command Line.
# Tomcat servlet container installation. sudo apt-get install tomcat9-user # Create new Tomcat instance. cd /home/dhis sudo tomcat9-instance-create tomcat-dhis sudo chown -R dhis:dhis tomcat-dhis cd -
-
Append the following lines to the /home/dhis/tomcat-dhis/bin/setenv.sh file.
export JAVA_HOME='/usr/lib/jvm/java-11-openjdk-amd64/' export JAVA_OPTS='-Xms4000m -Xmx7000m' export DHIS2_HOME='/home/dhis/config'
-
Modify the Tomcat /home/dhis/tomcat-dhis/conf/server.xml configuration file.
sudo cp -a /home/dhis/tomcat-dhis/conf/server.xml /home/dhis/tomcat-dhis/conf/server.xml.org sudo sed -i "s/8080/8888/" /home/dhis/tomcat-dhis/conf/server.xml
# Download DHIS2 WAR file. cd /home/dhis/tomcat-dhis/webapps sudo wget https://releases.dhis2.org/2.37/dhis2-stable-2.37.0.war sudo mv dhis2-stable-2.37.0.war ROOT.war sudo chown dhis:dhis ROOT.war cd -
sudo cp -a /home/dhis/tomcat-dhis/bin/startup.sh /home/dhis/tomcat-dhis/bin/startup.sh.org
sudo -u dhis /home/dhis/tomcat-dhis/bin/startup.sh # Run DHIS2. sudo -u dhis /home/dhis/tomcat-dhis/bin/shutdown.sh # Stop DHIS2. sudo tail -f /home/dhis/tomcat-dhis/logs/catalina.out # Monitor DHIS2. # Access DHIS2. http://localhost:8888 http://10.10.1.5:8888
-
Type
adminfor the user name. -
Type
districtfor the password. -
Uncheck Login using two factor authentication.
-
Click Sign in.
-
Do your thing.
-
Select AA > Logout.
1.4. Usage
-
Enter the following commands at a Command Line.
sudo -u dhis psql --dbname dhis2 \dt \q