How to Install OpenMRS (Open Medical Record System) on Debian 11

OpenMRS stands for "Open Medical Record System", is a free, open-source, and efficient electronic medical record (EMR) storage and retrieval system. It is used for treating millions of HIV/AIDS and tuberculosis (TB) patients in the developing world. Its main aim is to develop software for delivering health care in developing countries. It allows the exchange of patient data with other medical information systems. It is written in Java and provides a user-friendly web dashboard for managing electronic medical records through the web browser.

In this post, we will show you how to install OpenMRS Medical Record System on Debian 11.

Prerequisites

  • A server running Debian 11.
  • A root password is configured on the server.

Install Java 8

OpenMRS is a Java-based application and only supports Java version 8. So you will need to install Java 8 on your server. By default, Java 8 is not included in the Debian 11 default repository. So you will need to download and install it from their official website.

First, create a directory for Java using the following command:

mkdir -p /usr/lib/jvm/

Next, extract the downloaded Java source file with the following command:

tar -zxvf jdk-8u281-linux-x64.tar.gz -C /usr/lib/jvm/

Next, install the Java 8 using the following command:

update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.8.*/bin/java 1

Once Java is installed, verify the Java version using the following command:

java -version

You will get the following output:

java version "1.8.0_281"
Java(TM) SE Runtime Environment (build 1.8.0_281-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.281-b09, mixed mode)

Install MySQL Server 5.6

OpenMRS only supports MySQL version 5.6. By default, MySQL 5.6 is not available in the Debian 11 default repository. So you will need to install it from the source.

First, create a user and group for MySQL using the following command:

groupadd mysql
useradd -g mysql mysql

Next, download MySQL 5.6 source with the following command:

wget https://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.46-linux-glibc2.12-x86_64.tar.gz

Once the MySQL is downloaded, extract it with the following command:

tar -xvf mysql-5.6.46-linux-glibc2.12-x86_64.tar.gz

Next, move the extracted directory to /usr/local with the following command:

mv mysql-5.6.46-linux-glibc2.12-x86_64 /usr/local/mysql

Next, navigate to the /usr/local directory and set proper ownership with the following command:

cd /usr/local/mysql
chown -R mysql:mysql *

Next, install the required dependencies using the following command:

apt-get install libaio1 libncurses5 libnuma-dev -y

Next, install MySQL with the following command:

scripts/mysql_install_db --user=mysql

You will get the following output:

You can start the MySQL daemon with:

  cd . ; ./bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl

  cd mysql-test ; perl mysql-test-run.pl

Please report any problems at http://bugs.mysql.com/

The latest information about MySQL is available on the web at

  http://www.mysql.com

Support MySQL by buying support/licenses at http://shop.mysql.com

New default config file was created as ./my.cnf and
will be used by default by the server when you start it.
You may edit this file to change server settings

Next, set proper ownership to MySQL directory and data directory:

chown -R root .
chown -R mysql data

Next, copy MySQL configuration file and service file:

cp support-files/my-default.cnf /etc/my.cnf
cp support-files/mysql.server /etc/init.d/mysql.server

Next, start the MySQL service in safe mode:

bin/mysqld_safe --user=mysql &

Next, set the MySQL root password with the following command:

bin/mysqladmin -u root password newpassword

Next, create a symblolic link of the mysql binary using the following command:

ln -s /usr/local/mysql/bin/mysql /usr/local/bin/mysql

Finally, restart your server with the following command:

reboot

After the system restart, start the MySQL service and enable it to start at system reboot:

/etc/init.d/mysql.server start
update-rc.d -f mysql.server defaults

You can also check the status of the MySQL service with the following command:

/etc/init.d/mysql.server status

You will get the following output:

? mysql.server.service - LSB: start and stop MySQL
     Loaded: loaded (/etc/init.d/mysql.server; generated)
     Active: active (running) since Fri 2022-03-25 14:35:35 UTC; 5s ago
       Docs: man:systemd-sysv-generator(8)
    Process: 415 ExecStart=/etc/init.d/mysql.server start (code=exited, status=0/SUCCESS)
      Tasks: 22 (limit: 4679)
     Memory: 460.5M
        CPU: 826ms
     CGroup: /system.slice/mysql.server.service
             ??422 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/usr/local/mysql/data --pid-file=/usr/local/mysql/data/debian11.pid
             ??530 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/p…

Mar 25 14:35:34 debian11 systemd[1]: Starting LSB: start and stop MySQL...
Mar 25 14:35:34 debian11 mysql.server[415]: Starting MySQL
Mar 25 14:35:35 debian11 mysql.server[415]: ..
Mar 25 14:35:35 debian11 systemd[1]: Started LSB: start and stop MySQL.

Once you are finished, you can proceed to the next step.

Install Tomcat 7

Next, you will need to install Tomcat to deploy OpenMRS.

First, create a user and group for Tomcat with the following command:

groupadd tomcat
useradd -s /bin/false -g tomcat -d /opt/tomcat tomcat

Next, download the Tomcat 7 with the following command:

wget https://archive.apache.org/dist/tomcat/tomcat-7/v7.0.109/bin/apache-tomcat-7.0.109.tar.gz

Next, create a directory for Tomcat and extract the downloaded file to /opt/tomcat directory:

mkdir /opt/tomcat
tar -xvzf apache-tomcat-7.0.109.tar.gz -C /opt/tomcat/ --strip-components=1

Next, navigate to the /opt/tomcat directory and set proper permission and ownership:

cd /opt/tomcat
chgrp -R tomcat /opt/tomcat
chmod -R g+r conf
chmod g+x conf
chown -R tomcat webapps/ work/ temp/ logs/

Once you are finished, you can proceed to the next step.

Create a Systemd Service File for Tomcat

Next, you will need to create a systemd service file to manage the Tomcat service. You can create it with the following command:

nano /etc/systemd/system/tomcat.service

Add the following lines:

[Unit]
Description=Apache Tomcat Web Application Container
After=network.target
[Service]
Type=forking
Environment=JAVA_HOME=/usr/lib/jvm/jdk1.8.0_281
Environment=CATALINA_PID=/opt/tomcat/temp/tomcat.pid
Environment=CATALINA_HOME=/opt/tomcat
Environment=CATALINA_BASE=/opt/tomcat
Environment=’CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC’
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

Save and close the file, then reload the systemd daemon to apply the changes:

systemctl daemon-reload

Next, start the Tomcat service with the following command:

systemctl start tomcat

You can now check the status of the Tomcat service with the following command:

systemctl status tomcat

You will get the following output:

? tomcat.service - Apache Tomcat Web Application Container
     Loaded: loaded (/etc/systemd/system/tomcat.service; disabled; vendor preset: enabled)
     Active: active (running) since Fri 2022-03-25 14:38:45 UTC; 5s ago
    Process: 648 ExecStart=/opt/tomcat/bin/startup.sh (code=exited, status=0/SUCCESS)
   Main PID: 655 (java)
      Tasks: 28 (limit: 4679)
     Memory: 136.3M
        CPU: 4.124s
     CGroup: /system.slice/tomcat.service
             ??655 /usr/lib/jvm/jdk1.8.0_281/bin/java -Djava.util.logging.config.file=/opt/tomcat/conf/logging.properties -Djava.util.logging>

Mar 25 14:38:45 debian11 systemd[1]: Starting Apache Tomcat Web Application Container...
Mar 25 14:38:45 debian11 startup.sh[648]: Tomcat started.
Mar 25 14:38:45 debian11 systemd[1]: Started Apache Tomcat Web Application Container.

At this point, Tomcat is started and listens on port 8080.

Install OpenMRS

First, create a directory for OpenMRS and set proper ownership with the following command:

mkdir /var/lib/OpenMRS
chown -R tomcat:tomcat /var/lib/OpenMRS

Next, download the latest version of OpenMRS using the following command:

wget https://sourceforge.net/projects/openmrs/files/releases/OpenMRS_Platform_2.5.0/openmrs.war

Once the download is completed, copy the downloaded file to the Tomcat webapps directory:

cp openmrs.war /opt/tomcat/webapps/

Next, change the ownership of the openmrs.war file to tomcat:

chown -R tomcat:tomcat /opt/tomcat/webapps/openmrs.war

Once you are finished, you can proceed to the next step.

Access OpenMRS Installation Wizard

Now, open your web browser and access the OpenMRS web installation wizard using the URL http://your-server-ip:8080/openmrs. You should see the OpenMRS language selection screen:

OpenMRS Installation Wizard

Select your language and click on the => button. You should see the Installation Type screen.

Installation Type

Select the type of installation you want and click on the => button. You should see the following screen:

Set a Password

Provide your MySQL root password, note down the admin password, and click on the => button. You should see the following screen:

Confirm installation parameters

Implementation

Click on the => button to create a database for OpenMRS and complete the installation.

Now, open your web browser and access the OpenMRS admin interface using the URL http://your-server-ip:8080/openmrs. You should see the OpenMRS login screen:

OpenMRS Login

Provide the default username as admin and password as Admin123, then click on the LOG IN button. You should see the OpenMRS dashboard on the following screen:

OpenMRS dashboard

Conclusion

Congratulations! you have successfully installed OpenMRS on Debian 11. You can now easily store and manage electronic medical records via a web browser. Feel free to ask me if you have any questions.

Share this page:

0 Comment(s)