dhis2 installation in ubuntu
1. create a user in ubuntu for dhis2
sudo useradd -d /home/dhis -m dhis -s /bin/bash
Here username: dhis
2. give permission the user as root
sudo usermod -G sudo dhis
3. set password for user "dhis"
sudo passwd dhis
password: soft@works
4. stop root remote login for security
sudo passwd -l root //(SKIP this command for local practice)
5. create a root config directory for dhis2
sudo mkdir /home/dhis/config
6. set time zone
sudo dpkg-reconfigure tzdata
7. set locale
sudo locale -a (see locale list - sudo locale -av)
sudo locale-gen en_US.UTF-8
8. check postgreSQL (psql) is installed or not
sudo which psql
ubuntu 14.04 has the version 9.3
( Try to install default repository postgreSQL in the system otherwise get the followings)
install postgreSQL 9.4
sudo apt-get install postgresql-9.4 postgresql-9.4-postgis-2.2 postgresql-contrib-9.4
but it has no direct repository for 9.4
follow the link for installation 9.4
https://www.postgresql.org/download/linux/ubuntu/
Create the file /etc/apt/sources.list.d/pgdg.list, and add a line for the repository deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main
Import the repository signing key, and update the package lists wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | \
sudo apt-key add -
sudo apt-get update
sudo nano /etc/apt/sources.list.d/pgdg.list
paste: deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get install postgresql-9.4
9. switch ubuntu user to postgres
sudo su postgres
(NOTE optional: If you need to drop db from the root
sudo -u postgres psql -c "SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE pid <> pg_backend_pid() AND datname = 'dhis2';"
sudo -u postgres psql -c "DROP DATABASE dhis2")
10. create a db user name "dhis"
createuser -SDRP dhis
password: soft@works
11. create a database "dhis2" by the user dhis
createdb -O dhis dhis2
12. switch to user (anwar) from postgres, dont use "sudo", postgres have no sudo access
su anwar
13. create a file for postgres configuration
sudo nano /home/dhis/config/dhis.conf
14. paste content
# 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
# Database username
connection.username = dhis
# Database password
connection.password = soft@works
# Database schema behavior, can be validate, update, create, create-drop
connection.schema = update
# Encryption password (sensitive)
#encryption.password = soft@works //commented by Anwar
16. change config file permission
sudo chmod 0600 /home/dhis/config/dhis.conf
17. java installation
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer
18. check java version
java -version
19 set default current manually installed java version
sudo apt-get install oracle-java8-set-default
20. Install Tomcat and DHIS2
sudo apt-get install tomcat7-user
21. create tomcat instance for the user dhis
sudo tomcat7-instance-create tomcat-dhis
22 edit file
sudo nano /tomcat-dhis/bin/setenv.sh
paste:
export JAVA_HOME='/usr/lib/jvm/java-8-oracle/'
export JAVA_OPTS='-Xmx7500m -Xms4000m'
export DHIS2_HOME='/home/dhis/config'
Note: JAVA_OPTS='-Xmx1600m -Xms1600m' when your memory 4 GB
23. tomcat configuration
sudo nano /tomcat-dhis/conf/server.xml
it is already pasted i found
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443"
URIEncoding="UTF-8" />
*** connection time out should be 50000 for localhost low memory environment
24. download dhis2 war file
sudo wget https://www.dhis2.org/download/releases/2.23/dhis.war
25. move war to tomcat-dhis/webapps directory
sudo mv dhis.war tomcat-dhis/webapps/ROOT.war
26. run dhis2
sudo tomcat-dhis/bin/startup.sh
(dhis2 can be stopped: tomcat-dhis/bin/shutdown.sh)
It may happen dhis2 will not run at first time of tomcat start
Please stop and start again will ensure you dhis2 running
27. to see the log
sudo tail -f tomcat-dhis/logs/catalina.out
28. start tomcate at startup time
sudo nano /home/dhis/config/tomcat
paste:
#!/bin/sh
#Tomcat init script
HOME=/tomcat-dhis/bin
case $1 in
start)
sh ${HOME}/startup.sh
;;
stop)
sh ${HOME}/shutdown.sh
;;
restart)
sh ${HOME}/shutdown.sh
sleep 5
sh ${HOME}/startup.sh
;;
esac
exit 0
29. move tomcat file to init directory
sudo mv /home/dhis/config/tomcat /etc/init.d
sudo chmod +x /etc/init.d/tomcat
30. add the file to the startup list
sudo /usr/sbin/update-rc.d -f tomcat defaults 81
---------------------------------------------------------
sudo /tomcat-dhis/bin/shutdown.sh
sudo useradd -d /home/dhis -m dhis -s /bin/bash
Here username: dhis
2. give permission the user as root
sudo usermod -G sudo dhis
3. set password for user "dhis"
sudo passwd dhis
password: soft@works
4. stop root remote login for security
sudo passwd -l root //(SKIP this command for local practice)
5. create a root config directory for dhis2
sudo mkdir /home/dhis/config
6. set time zone
sudo dpkg-reconfigure tzdata
7. set locale
sudo locale -a (see locale list - sudo locale -av)
sudo locale-gen en_US.UTF-8
8. check postgreSQL (psql) is installed or not
sudo which psql
ubuntu 14.04 has the version 9.3
( Try to install default repository postgreSQL in the system otherwise get the followings)
install postgreSQL 9.4
sudo apt-get install postgresql-9.4 postgresql-9.4-postgis-2.2 postgresql-contrib-9.4
but it has no direct repository for 9.4
follow the link for installation 9.4
https://www.postgresql.org/download/linux/ubuntu/
Create the file /etc/apt/sources.list.d/pgdg.list, and add a line for the repository deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main
Import the repository signing key, and update the package lists wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | \
sudo apt-key add -
sudo apt-get update
sudo nano /etc/apt/sources.list.d/pgdg.list
paste: deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get install postgresql-9.4
9. switch ubuntu user to postgres
sudo su postgres
(NOTE optional: If you need to drop db from the root
sudo -u postgres psql -c "SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE pid <> pg_backend_pid() AND datname = 'dhis2';"
sudo -u postgres psql -c "DROP DATABASE dhis2")
10. create a db user name "dhis"
createuser -SDRP dhis
password: soft@works
11. create a database "dhis2" by the user dhis
createdb -O dhis dhis2
12. switch to user (anwar) from postgres, dont use "sudo", postgres have no sudo access
su anwar
13. create a file for postgres configuration
sudo nano /home/dhis/config/dhis.conf
14. paste content
# 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
# Database username
connection.username = dhis
# Database password
connection.password = soft@works
# Database schema behavior, can be validate, update, create, create-drop
connection.schema = update
# Encryption password (sensitive)
#encryption.password = soft@works //commented by Anwar
16. change config file permission
sudo chmod 0600 /home/dhis/config/dhis.conf
17. java installation
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer
18. check java version
java -version
19 set default current manually installed java version
sudo apt-get install oracle-java8-set-default
20. Install Tomcat and DHIS2
sudo apt-get install tomcat7-user
21. create tomcat instance for the user dhis
sudo tomcat7-instance-create tomcat-dhis
22 edit file
sudo nano /tomcat-dhis/bin/setenv.sh
paste:
export JAVA_HOME='/usr/lib/jvm/java-8-oracle/'
export JAVA_OPTS='-Xmx7500m -Xms4000m'
export DHIS2_HOME='/home/dhis/config'
Note: JAVA_OPTS='-Xmx1600m -Xms1600m' when your memory 4 GB
23. tomcat configuration
sudo nano /tomcat-dhis/conf/server.xml
it is already pasted i found
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443"
URIEncoding="UTF-8" />
*** connection time out should be 50000 for localhost low memory environment
24. download dhis2 war file
sudo wget https://www.dhis2.org/download/releases/2.23/dhis.war
25. move war to tomcat-dhis/webapps directory
sudo mv dhis.war tomcat-dhis/webapps/ROOT.war
26. run dhis2
sudo tomcat-dhis/bin/startup.sh
(dhis2 can be stopped: tomcat-dhis/bin/shutdown.sh)
It may happen dhis2 will not run at first time of tomcat start
Please stop and start again will ensure you dhis2 running
27. to see the log
sudo tail -f tomcat-dhis/logs/catalina.out
28. start tomcate at startup time
sudo nano /home/dhis/config/tomcat
paste:
#!/bin/sh
#Tomcat init script
HOME=/tomcat-dhis/bin
case $1 in
start)
sh ${HOME}/startup.sh
;;
stop)
sh ${HOME}/shutdown.sh
;;
restart)
sh ${HOME}/shutdown.sh
sleep 5
sh ${HOME}/startup.sh
;;
esac
exit 0
29. move tomcat file to init directory
sudo mv /home/dhis/config/tomcat /etc/init.d
sudo chmod +x /etc/init.d/tomcat
30. add the file to the startup list
sudo /usr/sbin/update-rc.d -f tomcat defaults 81
---------------------------------------------------------
Tomcat start and stop in dhis2
sudo /tomcat-dhis/bin/startup.shsudo /tomcat-dhis/bin/shutdown.sh
There is insufficient memory for the Java Runtime Environment to continue.
ReplyDelete# Native memory allocation (mmap) failed to map 1162870784 bytes for committing reserved memory.
hs_err_pid1424.log file location in the root
cd /
Solution: JAVA_OPTS='-Xmx1600m -Xms1600m' when your memory is low (4 GB)