How make 2 DHIS2 instances on a Single Server

How make 2 DHIS2 instances on a Single Server

2 Likes

Hi @daniel1
You can follow the installation instructions here:

When you get to the section “Creating a user for DHIS2” and “Creating the configuration directory”, repeat those steps for each DHIS2 instance you want to run on the machine - in other words, create a user for each DHIS2 instance.
Similarly, for the DHIS2 configuration section, make sure you create a different configuration for each instance - one in each home directory for the user you created above.

For the Tomcat and DHIS2 installation, run the first step (sudo apt-get install tomcat8-user), then for the next steps, follow those for each dhis2 instance user you created above.

Lastly, you can start your DHIS2 instances individually like this:

sudo -u [dhisuser1] /home/[dhis2user1]/tomcat-dhis/bin/startup.sh
sudo -u [dhisuser2] /home/[dhis2user2]/tomcat-dhis/bin/startup.sh
sudo -u [dhisuser3] /home/[dhis2user3]/tomcat-dhis/bin/startup.sh

…etc
Replace [dhis2userx] with your individual user accounts you created.

To automatically start them at reboot, add an entry to the crontab for each user to run the command above on reboot:

sudo su - [dhisuser1]
crontab -e

Add this to the cron file and save it:

@reboot ~/tomcat-dhis/bin/startup.sh

Repeat these commands for each user / instance of DHIS2
It’s important to note that you must start each instance as the user account that the instance was created under - if you take shortcuts and run tomcat as sudo, the ownership of various files will be adjusted to the root user which will create problems when running it as the correct user. If you accidentally do this, just set ownership for the home directory and it’s contents with sudo chown -R [dhis2user1]:[dhis2user1] /home/[dhis2user1]
Replace [dhis2user1] with the user name

Let me know if any of this doesn’t make sense?

3 Likes

Thank you @Edward_Robinson for the support! :wave:

@daniel1 would you like to update us if you found the answer please? Feel free to post if you have more questions. Thank you!

1 Like