Installing An OpenMRS Server On Linux


Most of the installation steps will work on Linux as well as Windows, with the following additions/exceptions.

  • Some of the default runtime configuration settings will need to be adjusted for Linux — e.g., file paths
  • For FormEntry, you must install lcab (see Setting up lcab section below)


Contents

Known Platforms

  1. SUSE Linux Enterprise Server 10 - James Arbaugh
  2. SUSE 9.1 - James Arbaugh
  3. Ubuntu 7.04 QEMU - Phillipe Boucher
  4. Mac OS X, Ubuntu 8.04, Debian 4 - Yaw Anokwa

Prepare the Linux Server

Detailed Instructions for setting up OpenMRS on SUSE Linux Enterprise Server 10 SP 1 Provided by James Arbaugh Deschapelles, Haiti

MySQL

MySQL should be installed by default, if not, install it through your package manager (e.g. Yast or Aptitude).

  1. Setup the MySQL users/privileges
    1. Set the root password. Substitute ‘myrootpassword’ with your desired root password.
      1. /usr/bin/mysqladmin -u root password ‘rootpassword'
    2. Start mysql as root.
      1. mysql --user=root -p <ENTER>
    3. Type the following to create a password for root:
      1. GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY 'rootpassword' WITH GRANT OPTION; <ENTER>
      2. GRANT ALL PRIVILEGES ON *.* TO 'root'@'YOURSERVERNAME' IDENTIFIED BY 'rootpassword' WITH GRANT OPTION; <ENTER>
      3. FLUSH PRIVILEGES;
  2. Import the MySQL database tables for OpenMRS data
    1. Log into the mysql client utility if you are not already logged in
      1. mysql --user=root -p <ENTER>
    2. Create the databases type:
      1. CREATE DATABASE openmrs COLLATE utf8_general_ci; <ENTER>
    3. Close the mysql client. Type: exit <ENTER>
    4. Type the following command followed by the Enter key. This could either be a database dump from a former installation, or the default sql script/sqldiff script which comes with OpenMRS. Note the path to the sql backup file and the database name…
      1. mysql --user=root -p -h localhost openmrs < /PATH/TO/SQL/FILE/openmrs_backup.sql <ENTER>

Java

  1. Download the Java 2 JDK (http://java.sun.com/javase/downloads/index.jsp)
  2. Install Java Note: The file name and path may be different depending on the version of Java downloaded
    1. ./jdk-6u1-linux-amd64-rpm.bin <ENTER>
  3. Set Java environment variables
    1. Type: vi /etc/bash.bashrc.local <ENTER>
    2. Add the following (Shift-I)…
      1. export JAVA_HOME=/usr/java/jdk1.6.0_01
      2. export JAVA_JRE=/usr/java/jdk1.6.0_01
      3. export PATH=$PATH:$JAVA_HOME/bin:.:/usr/java/jdk1.6.0_01/bin
    3. Save and exit vi. (:wq)
  4. Restart the server.

Tomcat

  1. Move to the desired extraction directory.
    1. cd /srv/www/ <ENTER>
  2. Download the latest stable version of Tomcat (used 5.5.23 at time of writing)…
    1. wget http://www.apache.org/dist/tomcat/tomcat-5/v5.5.23/bin/apache-tomcat-5.5.23.tar.gz <ENTER>
  3. Untar the downloaded file
    1. tar xvfz apache-tomcat-5.5.23.tar.gz <ENTER>
  4. Set environment variables
    1. Type: vi /etc/bash.bashrc.local <ENTER>
    2. Add the following…
      1. export CATALINA_HOME=/srv/www/apache-tomcat-5.5.23
  5. [OPTIONAL]Configure tomcat to run on a different port (Example shows changing to non-secure port 8081.)
    1. Edit /srv/www/apache-tomcat-5.5.23/conf/server.xml
    2. Change the entry for port 8080 (which conflicts with Dansguardian) to port 8081.
    3. It will look something like this once changed…
      1. ""
      2. <Connector port="8081" maxHttpHeaderSize="8192"
  6. Configure a username and password for tomcat
    1. Edit /srv/www/apache-tomcat-5.5.23/conf/tomcat-users.xml
    2. The file should look something like this, with MYPASSWORD being replaced with your password information.
      1. <tomcat-users>
      2. <role rolename="tomcat"/>
      3. <role rolename="manager"/>
      4. <role rolename="admin"/>
      5. <user username="tomcat" password="MYPASSWORD" roles="tomcat,admin,manager"/>
      6. <user username="root" password="MYPASSWORD" roles="admin,manager"/>
      7. </tomcat-users>
  7. Create the tomcat5 user and apply permissions
    1. Use Yast to create a new user named tomcat5. Use a really strong password.
    2. chown –R tomcat5 /srv/www/apache-tomcat-5.5.23/ <ENTER>
  8. Create the startup daemon tool (jsvc)
    1. cd $CATALINA_HOME/bin <ENTER>
    2. tar xvfz jsvc.tar.gz <ENTER>
    3. cd jsvc-src <ENTER>
    4. chmod 755 configure <ENTER>
    5. ./configure --with-java=/usr/java/jdk1.6.0_01 <ENTER>
    6. make <ENTER>
    7. cp jsvc .. <ENTER>
    8. cd .. <ENTER>
  9. Copy the startup script into place and edit it
    1. cp /srv/www/apache-tomcat-5.5.23/bin/jsvc-src/native/Tomcat5.sh /etc/rc.d/tomcat <ENTER>
    2. cd /etc/rc.d <ENTER>
    3. chmod 755 tomcat <ENTER>
    4. Customize it…
      1. JAVA_HOME=/usr/java/jdk1.6.0_01
      2. CATALINA_HOME=/srv/www/apache-tomcat-5.5.23
      3. DAEMON_HOME=/srv/www/apache-tomcat-5.5.23/bin
      4. TOMCAT_USER=tomcat5
      5. TMP_DIR=/var/tmp
      6. PID_FILE=/var/run/jsvc.pid
      7. CATALINA_BASE=/srv/www/apache-tomcat-5.5.23
      8. CATALINA_OPTS="-Djava.library.path=/srv/www/apache-tomcat-5.5.23/common/lib/.libs"
      9. CLASSPATH=\
      10. $JAVA_HOME/lib/tools.jar:\
      11. $CATALINA_HOME/bin/commons-daemon.jar:\
      12. $CATALINA_HOME/bin/bootstrap.jar
    5. Also, make a change to the start and stop sections to the following…
      1. $DAEMON_HOME/jsvc \
  10. Configure mysql and tomcat to run automatically at startup
    1. In Yast, System, System Services (runlevel)
    2. Go to mysql, and enable it.
    3. Go to tomcat, and enable it.
      1. NOTE It may be necessary to rename the tomcat files created under /etc/rc.d/rc3.d and /etc/rc.d/rc5.d to a greater S number so it starts later.
  11. Restart the server and test it out.
  12. [OPTIONAL] Use an example start/debug/stop script if you prefer not to automatically run tomcat at startup.
    1. Download: Tomcat.txt
    2. Place in a convenient location on the file system.
    3. Customize it as noted above.
    4. Run it from the command line, or
    5. Create a menu item and run it as an application in terminal.
    6. Usage:
      • $sudo ./Tomcat.sh start
      • $sudo ./Tomcat.sh stop
      • $sudo ./Tomcat.sh start debug
  13. [OPTIONAL] Advanced Configuration – Run Tomcat on SSL secure port 8443
    1. $JAVA_HOME/bin/keytool -genkey -alias tomcat -keyalg RSA <ENTER>
    2. Complete the information for the security certificate.
    3. vi $CATALINA_HOME/conf/server.xml <ENTER>
    4. Uncomment the SSL section. Delete “” before and after the SSL section. It should look like this…
      1. <Connector port="8443" maxHttpHeaderSize="8192"
    5. Restart the tomcat service.
      1. /etc/rc.d/tomcat stop <ENTER>
      2. /etc/rc.d/tomcat start <ENTER>
    6. Try access at https://YOURSERVERADDRESS:8443

OpenMRS

Setting up lcab

For Suse Linux 9.0, Suse Enterprise Linux 10 and RedHat EL 5, the following appears to work:

  1. Download LCAB from the Resources Section listed below. As of this update, version lcab 1.0b12 was used.
  2. Go to the directory where you downloaded the LCAB file.
  3. Untar/unzip the file. Type: tar -xzvf lcab-1.0b12.tar.gz <ENTER>
  4. Go to the directory where you extracted the tar file. Type: cd lcab-1.0b12/ <ENTER>
  5. Configure the Makefile. Type: ./configure <ENTER>
  6. Compile it. Type: make <ENTER>
  7. Install LCAB. Type: make install <ENTER>
  8. It reports something like¦
    make[1]: Entering directory `/rpms/lcab-1.0b12'
       /bin/sh ./mkinstalldirs /usr/local/bin
       /usr/bin/install -c lcab /usr/local/bin/lcab
    make[1]: Nothing to be done for `install-data-am'.
    make[1]: Leaving directory `/rpms/lcab-1.0b12'

An XSN file will now be able to be downloaded in OpenMRS.

Install cabextract 1.2 (Required for Form upload)

  1. Download cabextract 1.2 from http://www.kyz.uklinux.net/cabextract.php
    1. wget http://www.kyz.uklinux.net/downloads/cabextract-1.2-1.i386.rpm
  2. Install the RPM
    1. rpm -vh cabextract-1.2-1.i386.rpm

Create the OPENMRS_RUNTIME_PROPERTIES_FILE

Note: as of OpenMRS 1.5, it is no longer necessary to create the OPENMRS_RUNTIME_PROPERTIES_FILE. When you deploy the openmrs.war file it will automatically walk you through a wizard to create this.

  1. Go to /home/tomcat5/.OpenMRS/
  2. Create a file called OPENMRS_RUNTIME_PROPERTIES.PROPERTIES
  3. It should look something like this…
#OPENMRS_BUILD_PROPERTIES_FILE
webapp.name=openmrs
webapp.display.name=OpenMRS
webapp.description=Open-Source EMR
###Properties for running unit tests with tomcat###
tomcat.server=localhost
tomcat.port=8081 [NOTE] This is using the alternate port
tomcat.manager.url=http://${tomcat.server}:${tomcat.port}/manager
tomcat.username=tomcat
tomcat.password=tomcat
### Database connection properties
connection.username=MYUSERNAME
connection.password=MYPASSWORD
connection.url=jdbc:mysql://localhost:3306/openmrs?autoReconnect=true

Create the environment variable for OPENMRS_RUNTIME_PROPERTIES_FILE

Note: as of OpenMRS 1.5, it is no longer necessary to create the environment variable for the OPENMRS_RUNTIME_PROPERTIES_FILE. When you deploy the openmrs.war file it will automatically walk you through a wizard to create the properties file in a place where it knows where it is at.

  1. Type: vi /etc/bashrc <ENTER>
  2. Add the following
    1. export OPENMRS_RUNTIME_PROPERTIES_FILE=/home/tomcat5/.OpenMRS/OPENMRS_RUNTIME_PROPERTIES.PROPERTIES
  3. Restart the server.

Deploy OpenMRS WAR file

  1. Browse to the Tomcat Manager which should be available at…
    1. http://YOURSERVERIP:8081/manager/html [NOTE] This is using the alternate port
  2. Select the WAR file to upload, and click Deploy.
  3. For full instructions, see the section called Deploy OpenMRS at
    1. http://openmrs.org/wiki/Step-by-Step_Installation_for_Implementers
  4. Log into OpenMRS at
    1. http://YOURSERVERIP:8081/openmrs [NOTE] This is using the alternate port

Resources