Installing OpenMRS on OpenShift

This page is outdated and no longer receives updates!

OpenShift is a PAAS by RedHat one may use for easy OpenMRS deployment with low initial cost and easy scaling. Unlike IAAS (VDS such as EC2) it does not require manual server administration - one may just deploy an app, while care of hosting management is taken by RedHat.

This guide assumes you already have an OpenShift account with domain selected and SSH keys added.

Commands specified are valid for *nix environment, adaptation to others is trivial though.

Video Guide: Deploying OpenMRS on OpenShift on Mac or Linux

Installing OpenMRS on OpenShift - Abbreviated for Mac and Linux

Video Guide: Deploying OpenMRS on OpenShift on Windows

Installing OpenMRS on OpenShift - Abbreviated for Windows

 

You should replace variables (such as $OPENSHIFT_APP_UUID) with their real values except while working on the server/having them declared in some other way.

Step-by-step guide

  1. Add a DIY cartridge.

  2. Add MySQL cartridge to the previously created one (OpenShift console -> cartridge -> Databases -> Add MySQL).

  3. Prepare to change the cartridge:

    1. Clone its repository: 

      1. git clone ssh://$OPENSHIFT_APP_UUID@$OPENSHIFT_APP_DNS/~/git/openmrs.git/

    2. Move to the resulting directory:

      1. cd openmrs/

  4. Deploy custom Tomcat (Custom here means not the default one for OpenShift. In fact, this variant is upstream.)

    1. git remote add tomcat-upstream -m master git://github.com/openshift-quickstart/openshift-tomcat-quickstart.git

    2. git pull -s recursive -X theirs tomcat-upstream master

    3. git push

    4. Check if Tomcat has started successfully by visiting your server via browser (URL is written on cartridge's page in console).

  5. Deploy OpenMRS to server:

    1. Download the app archive (version specified here is the most recent one by the time of writing) into tomcat webapps directory:

      1. curl -L http://sourceforge.net/projects/openmrs/files/releases/OpenMRS_Platform_1.10.1/openmrs.war/download -o diy/tomcat/webapps/openmrs.war

    2. git add diy/tomcat/webapps/openmrs.war

    3. git commit -m 'Deployed OpenMRS Platform 1.10.1'

    4. git push

    5. Check if it has started succesfully by visiting http://$OPENSHIFT_APP_DNS/openmrs (default path).

  6. Configure OpenMRS on low level:

    1. Set proper OpenMRS configuration file path (via env var (see Overriding OpenMRS Default Runtime Properties)):

      1. ssh to the server

      2. echo "/var/lib/openshift/$OPENSHIFT_APP_UUID/app-deployments/current/repo/diy/openmrs/openmrs-runtime.properties" > .env/user_vars/OPENMRS_RUNTIME_PROPERTIES_FILE

      3. Exit the server

    2. Set proper app data directory (default is ~/.OpenMRS; these commands are to be run in the git repository associated with your cartridge):

      1. mkdir diy/openmrs

      2. echo "application_data_directory=/var/lib/openshift/$OPENSHIFT_APP_UUID/app-deployments/current/repo/diy/openmrs" > diy/openmrs/openmrs-runtime.properties

    3. Add MySQL configuration to OpenMRS config:

      1. echo "### Database connection properties
        connection.username=$OPENSHIFT_MYSQL_DB_USERNAME
        connection.password=$OPENSHIFT_MYSQL_DB_PASSWORD
        connection.url=jdbc:mysql://$OPENSHIFT_MYSQL_DB_HOST:$OPENSHIFT_MYSQL_DB_PORT/$OPENSHIFT_APP_NAME?autoReconnect=true" >> diy/openmrs/openmrs-runtime.properties

    4. Commit and push the changes:

      1. git add diy/openmrs/openmrs-runtime.properties

      2. git commit -m 'Configured OpenMRS'

      3. git push

  7. Proceed to high-level OpenMRS configuration via browser. You should not select 'Simple' as type of installation as it assumes having MySQL root, etc.

Don't forget to change your Tomcat manager password! (The default account is tomcat:openshift, can be altered by editing diy/tomcat/conf/tomcat-users.xml and pushing).

Related articles

Related pages