Linux Installation

Software Requirements for UgandaEMR

- Java JDK 8 
- Tomcat 7 or higher
- Mysql 5.6 or 5.7

Installation of Java

  1. Login as root in the linux environment

  2. Open the terminal and enter the following command to create the parent directory to deploy the JDK. sudo mkdir /usr/lib/jvm

  3. Enter the following command to change the directory cd /usr/lib/jvm

  4. Extract the jdk-8u361-linux-x64.tar.gz file in the jvm directory using this command

    sudo tar -xvzf /YourHomeDirectory/jdk-8u361-linux-x64.tar.gz

  5. Enter the following command to open the environment variables file. According to your personal preference, you can choose any text editor instead of nano. sudo nano /etc/environment

  6. In the opened file, add the following bin folders to the existing PATH variable. Note that the PATH variables must be separated by a colon.

    /usr/lib/jvm/jdk1.8.0_361/bin

    /usr/lib/jvm/jdk1.8.0_361/db/bin

    /usr/lib/jvm/jdk1.8.0_361/jre/bin

    Append the following environment variable to the end of the file.

    J2SDKDIR="/usr/lib/jvm/jdk1.8.0_361" 
    
    J2REDIR="/usr/lib/jvm/jdk1.8.0_361/jre"
    
    JAVA_HOME="/usr/lib/jvm/jdk1.8.0_361"

    A sample environment file before making these changes would look like the following:

     PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"

    The same file after making the changes should look like this:

    PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:
    /usr/lib/jvm/jdk1.8.0_361/bin:/usr/lib/jvm/jdk1.8.0_361/db/bin:/usr/lib/jvm/jdk1.8.0_361/jre/bin"
    
    J2SDKDIR="/usr/lib/jvm/jdk1.8.0_361"
    
    J2REDIR="/usr/lib/jvm/jdk1.8.0_361/jre"
    
    JAVA_HOME="/usr/lib/jvm/jdk1.8.0_361"
  7. Save the changes and close the editor

  8. Sometimes an existing JDK installation might have a shortcut added to the /usr/bin directory. Therefore setting the PATH environment variable alone may not change the default Java compiler and runtime. To update these alternative shortcuts, run the following commands:

    sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.8.0_351/bin/java" 0sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.8.0_351/bin/javac" 0sudo update-alternatives --set java /usr/lib/jvm/jdk1.8.0_351/bin/java

    sudo update-alternatives --set javac /usr/lib/jvm/jdk1.8.0_351/bin/javac

  9. To verify the setup enter the following commands and make sure that they print the location of java and javac as you have provided in the previous step.

    update-alternatives --list java

    update-alternatives --list javac

  10. Test version on terminal with command

  11. java -version

  12. If you are not able to see the version install missing linux libraries

    sudo apt-get install libc6-i386

Installation of Tomcat

Tomcat installation will require java which were previously installed as shown above

  1. sudo apt update

  2. Set up a Tomcat user sudo useradd -r -m -U -d /opt/tomcat -s /bin/false tomcat

  3. Download tomcat

wget -c https://archive.apache.org/dist/tomcat/tomcat-7/v7.0.109/bin/apache-tomcat-7.0.109.tar.gz 4. Install on linux sudo tar xf apache-tomcat-7.0.109.tar.gz -C /opt 5. Rename apache-tomcat-7.0.109 to tomcat

cd /opt

mv apache-tomcat-7.0.109 tomcat

  1. Now we need to provide the user Tomcat with access for the Tomcat installation directory

    sudo chown -R tomcat: /opt/tomcat/*

  2. Finally, we will use the chmod command to provide all executable flags to all scripts within the bin directory.

    sudo sh -c 'chmod +x /opt/tomcat/bin/*.sh'

  3. Configure Tomcat serice sudo nano /etc/systemd/system/tomcat.service

    Now enter the following in your file and save it. Note that you need to update the value of JAVA_HOME if your Java installation directory is not the same as given below.


    [Unit]
    Description=Apache Tomcat Web Application Container
    After=network.target
   
    [Service]
    Type=forking
      
    Environment="JAVA_HOME=/usr/lib/jvm/jdk1.8.0_361"
    Environment="CATALINA_PID=/opt/tomcat/temp/tomcat.pid"
    Environment="CATALINA_HOME=/opt/tomcat/"
    Environment="CATALINA_BASE=/opt/tomcat/"
    Environment="CATALINA_OPTS=-Xms1024M -Xmx2048M -server -XX:+UseParallelGC"
    Environment="JAVA_OPTS=-Djava.awt.headless=true -Djava.security.egd=file:/dev/./urandom"
      
    ExecStart=/opt/tomcat/bin/startup.sh
    ExecStop=/opt/tomcat/bin/shutdown.sh
      
    User=tomcat
    Group=tomcat
    UMask=0007
    RestartSec=10
    Restart=always
      
    [Install]
    WantedBy=multi-user.target
  1. Now we reload the daemon to update the system about the new file.

    sudo systemctl daemon-reload

  2. Start tomcat service sudo systemctl start tomcat

  3. Now we can enable the Tomcat service to run on startup using this command. sudo systemctl enable tomcat

  4. After you install Tomcat, you need to allow it to use the 8080 port through the firewall to be able to communicate outside your local network. sudo ufw allow 8080/tcp

  5. Once we install Tomcat on Linux, we need to verify our installation. To do so, simply enter the following in your browser.

  6. http://YourIPAddress:8080

  1. To enable tomcat to write in /var/lib , create the OpenMRS folder and make tomcat to own it using the commands below

    cd /var/lib

    mkdir OpenMRS

    sudo chown tomcat:tomcat OpenMRS/*

  2. Done.

Mysql 5.6 Installation

Guide for mysql installation is provided in link here Mysql Installation

Remember to create mysql user 'openmrs'

Deploying UgandaEMR on Linux

  1. Stop tomcat service sudo service tomcat stop

  2. copy war file to /opt/tomcat/webapps folder

  3. Start tomcat service sudo service tomcat start

  4. Access the system on browser via http://YourIPAddress:8080/openmrs

  5. You should see OpenMRS Installation Wizard page as below

  6. Select your preferred language and click the “=>” button.

  7. On the Installation Type screen, choose the Advanced installation type you want and click the “=>” button.

  8. Fill in your MySQL root password as shown below, and click the “=>” button.

  9. Fill the Next form as shown below and click the “=>” button.

  10. Fill in options as shown below and click the “=>” button.

  11. Fill in admin password as shown below and click the “=>” button.

  12. Skip next form click the “=>” button.

  13. And continue to finish the installation

  14. Drop openmrs database dump to openmrs database and restart tomcat service.

  15. Done Click the “=>” button to create a database for OpenMRS and complete the installation. Log in to OpenMRS using the default username “admin” and password “Admin123”.

Last updated