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 |
[edit]
Known Platforms
- SUSE Linux Enterprise Server 10 - James Arbaugh
- SUSE 9.1 - James Arbaugh
- Ubuntu 7.04 QEMU - Phillipe Boucher
- Mac OS X, Ubuntu 8.04, Debian 4 - Yaw Anokwa
[edit]
Prepare the Linux Server
Detailed Instructions for setting up OpenMRS on SUSE Linux Enterprise Server 10 SP 1 Provided by James Arbaugh Deschapelles, Haiti
[edit]
MySQL
MySQL should be installed by default, if not, install it through your package manager (e.g. Yast or Aptitude).
- Setup the MySQL users/privileges
- Set the root password. Substitute ‘myrootpassword’ with your desired root password.
- /usr/bin/mysqladmin -u root password ‘rootpassword'
- Start mysql as root.
- mysql --user=root -p <ENTER>
- Type the following to create a password for root:
- GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY 'rootpassword' WITH GRANT OPTION; <ENTER>
- GRANT ALL PRIVILEGES ON *.* TO 'root'@'YOURSERVERNAME' IDENTIFIED BY 'rootpassword' WITH GRANT OPTION; <ENTER>
- FLUSH PRIVILEGES;
- Set the root password. Substitute ‘myrootpassword’ with your desired root password.
- Import the MySQL database tables for OpenMRS data
- Log into the mysql client utility if you are not already logged in
- mysql --user=root -p <ENTER>
- Create the databases type:
- CREATE DATABASE openmrs COLLATE utf8_general_ci; <ENTER>
- Close the mysql client. Type: exit <ENTER>
- 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…
- mysql --user=root -p -h localhost openmrs < /PATH/TO/SQL/FILE/openmrs_backup.sql <ENTER>
- Log into the mysql client utility if you are not already logged in
[edit]
Java
- Download the Java 2 JDK (http://java.sun.com/javase/downloads/index.jsp)
- Install Java Note: The file name and path may be different depending on the version of Java downloaded
- ./jdk-6u1-linux-amd64-rpm.bin <ENTER>
- Set Java environment variables
- Type: vi /etc/bash.bashrc.local <ENTER>
- Add the following (Shift-I)…
- export JAVA_HOME=/usr/java/jdk1.6.0_01
- export JAVA_JRE=/usr/java/jdk1.6.0_01
- export PATH=$PATH:$JAVA_HOME/bin:.:/usr/java/jdk1.6.0_01/bin
- Save and exit vi. (:wq)
- Restart the server.
[edit]
Tomcat
- Move to the desired extraction directory.
- cd /srv/www/ <ENTER>
- Download the latest stable version of Tomcat (used 5.5.23 at time of writing)…
- Untar the downloaded file
- tar xvfz apache-tomcat-5.5.23.tar.gz <ENTER>
- Set environment variables
- Type: vi /etc/bash.bashrc.local <ENTER>
- Add the following…
- export CATALINA_HOME=/srv/www/apache-tomcat-5.5.23
- [OPTIONAL]Configure tomcat to run on a different port (Example shows changing to non-secure port 8081.)
- Edit /srv/www/apache-tomcat-5.5.23/conf/server.xml
- Change the entry for port 8080 (which conflicts with Dansguardian) to port 8081.
- It will look something like this once changed…
- ""
- <Connector port="8081" maxHttpHeaderSize="8192"
- Configure a username and password for tomcat
- Edit /srv/www/apache-tomcat-5.5.23/conf/tomcat-users.xml
- The file should look something like this, with MYPASSWORD being replaced with your password information.
- <tomcat-users>
- <role rolename="tomcat"/>
- <role rolename="manager"/>
- <role rolename="admin"/>
- <user username="tomcat" password="MYPASSWORD" roles="tomcat,admin,manager"/>
- <user username="root" password="MYPASSWORD" roles="admin,manager"/>
- </tomcat-users>
- Create the tomcat5 user and apply permissions
- Use Yast to create a new user named tomcat5. Use a really strong password.
- chown –R tomcat5 /srv/www/apache-tomcat-5.5.23/ <ENTER>
- Create the startup daemon tool (jsvc)
- cd $CATALINA_HOME/bin <ENTER>
- tar xvfz jsvc.tar.gz <ENTER>
- cd jsvc-src <ENTER>
- chmod 755 configure <ENTER>
- ./configure --with-java=/usr/java/jdk1.6.0_01 <ENTER>
- make <ENTER>
- cp jsvc .. <ENTER>
- cd .. <ENTER>
- Copy the startup script into place and edit it
- cp /srv/www/apache-tomcat-5.5.23/bin/jsvc-src/native/Tomcat5.sh /etc/rc.d/tomcat <ENTER>
- cd /etc/rc.d <ENTER>
- chmod 755 tomcat <ENTER>
- Customize it…
- JAVA_HOME=/usr/java/jdk1.6.0_01
- CATALINA_HOME=/srv/www/apache-tomcat-5.5.23
- DAEMON_HOME=/srv/www/apache-tomcat-5.5.23/bin
- TOMCAT_USER=tomcat5
- TMP_DIR=/var/tmp
- PID_FILE=/var/run/jsvc.pid
- CATALINA_BASE=/srv/www/apache-tomcat-5.5.23
- CATALINA_OPTS="-Djava.library.path=/srv/www/apache-tomcat-5.5.23/common/lib/.libs"
- CLASSPATH=\
- $JAVA_HOME/lib/tools.jar:\
- $CATALINA_HOME/bin/commons-daemon.jar:\
- $CATALINA_HOME/bin/bootstrap.jar
- Also, make a change to the start and stop sections to the following…
- $DAEMON_HOME/jsvc \
- Configure mysql and tomcat to run automatically at startup
- In Yast, System, System Services (runlevel)
- Go to mysql, and enable it.
- Go to tomcat, and enable it.
- 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.
- Restart the server and test it out.
- [OPTIONAL] Use an example start/debug/stop script if you prefer not to automatically run tomcat at startup.
- Download: Tomcat.txt
- Place in a convenient location on the file system.
- Customize it as noted above.
- Run it from the command line, or
- Create a menu item and run it as an application in terminal.
- Usage:
- $sudo ./Tomcat.sh start
- $sudo ./Tomcat.sh stop
- $sudo ./Tomcat.sh start debug
- [OPTIONAL] Advanced Configuration – Run Tomcat on SSL secure port 8443
- $JAVA_HOME/bin/keytool -genkey -alias tomcat -keyalg RSA <ENTER>
- Complete the information for the security certificate.
- vi $CATALINA_HOME/conf/server.xml <ENTER>
- Uncomment the SSL section. Delete “†before and after the SSL section. It should look like this…
- <Connector port="8443" maxHttpHeaderSize="8192"
- Restart the tomcat service.
- /etc/rc.d/tomcat stop <ENTER>
- /etc/rc.d/tomcat start <ENTER>
- Try access at https://YOURSERVERADDRESS:8443
[edit]
OpenMRS
[edit]
Setting up lcab
Justin has gotten this working for Partners In Health. Hopefully, he can edit this page and provide a recipe for setting up lcab on Linux. --Burke
For Suse Linux 9.0 and Suse Enterprise Linux 10 the following appears to work for Arbaughj…
- Download LCAB from the Resources Section listed below. As of this update, version “lcab 1.0b12†was used.
- Go to the directory where you downloaded the LCAB file.
- Unzip the file. Type: gunzip lcab-1.0b12.tar.gz <ENTER>
- Untar the file. Type: tar -xvf lcab-1.0b12.tar <ENTER>
- Go to the directory where you extracted the tar file. Type: cd lcab-1.0b12/ <ENTER>
- Configure the Makefile. Type: ./configure <ENTER>
- Compile it. Type: make <ENTER>
- Install LCAB. Type: make install <ENTER>
- 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.
[edit]
Install cabextract 1.2 (Required for Form upload)
- Download cabextract 1.2 from http://www.kyz.uklinux.net/cabextract.php
- Install the RPM
- rpm –Uvh cabextract-1.2-1.i386.rpm
[edit]
Create the OPENMRS_RUNTIME_PROPERTIES_FILE
- Go to… /home/tomcat5/.OpenMRS/
- Create a file called OPENMRS_RUNTIME_PROPERTIES.PROPERTIES
- 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
[edit]
Create the environment variable for OPENMRS_RUNTIME_PROPERTIES_FILE
- Type: vi /etc/bash.bashrc.local <ENTER>
- Add the following…
- export OPENMRS_RUNTIME_PROPERTIES_FILE=/home/tomcat5/.OpenMRS/OPENMRS_RUNTIME_PROPERTIES.PROPERTIES
- Restart the server.
[edit]
Deploy OpenMRS WAR file
- Browse to the Tomcat Manager which should be available at…
- http://YOURSERVERIP:8081/manager/html [NOTE] This is using the alternate port
- Select the WAR file to upload, and click Deploy.
- For full instructions, see the section called Deploy OpenMRS at
- Log into OpenMRS at
- http://YOURSERVERIP:8081/openmrs [NOTE] This is using the alternate port
[edit]
