OpenMRS is a powerful open-source electronic medical record (EMR) system that plays a crucial role in delivering healthcare in developing countries. Its ability to manage and exchange patient data with other medical information systems makes it a valuable tool for treating millions of HIV/AIDS and tuberculosis (TB) patients. In this tutorial, we will walk you through the step-by-step process of installing OpenMRS on Ubuntu 22.04, enabling you to leverage this efficient EMR storage and retrieval system.
Prerequisites
Before diving into the installation process, make sure you have the following prerequisites in place:
- A server running Ubuntu 22.04.
- A configured root password for the server.
Install OpenJDK 8
OpenMRS is a Java-based application that requires Java version 8. To install it on your server, follow these steps:
- Open your terminal and execute the following command to install OpenJDK 8:
apt install openjdk-8-jdk
- Verify the Java version by running:
java -version
If the output shows “openjdk version 1.8.0,” you have successfully installed Java 8.
Install MySQL Server 5.6
OpenMRS is compatible with MySQL version 5.6. Follow these steps to install MySQL server on your Ubuntu 22.04 server:
- Create a user and group for MySQL:
groupadd mysql
useradd -g mysql mysql
- Download MySQL 5.6 from the official website using the following command:
wget https://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.46-linux-glibc2.12-x86_64.tar.gz
- Extract the downloaded file:
tar -xvf mysql-5.6.46-linux-glibc2.12-x86_64.tar.gz
- Move the extracted directory to /usr/local:
mv mysql-5.6.46-linux-glibc2.12-x86_64 /usr/local/mysql
- Set proper ownership for the directory:
cd /usr/local/mysql chown -R mysql:mysql *
- Install the required dependencies:
apt-get install libaio1 libncurses5 libnuma-dev -y
- Run the MySQL installation script:
scripts/mysql_install_db --user=mysql
- Set ownership for the MySQL configuration file and service file:
chown -R root. chown -R mysql data
- Copy the MySQL configuration file and service file to their respective locations:
cp support-files/my-default.cnf /etc/my.cnf cp support-files/mysql.server /etc/init.d/mysql.server
- Start the MySQL service in safe mode:
bin/mysqld_safe --user=mysql &
- Set the MySQL root password:
bin/mysqladmin -u root password secure-password
- Create a symbolic link for the MySQL binary:
ln -s /usr/local/mysql/bin/mysql /usr/local/bin/mysql
- Restart your server:
reboot
Install Tomcat 8
Next, you need to install Tomcat 8 to deploy OpenMRS. Follow these steps:
- Create a user and group for Tomcat:
groupadd tomcat useradd -s /bin/false -g tomcat -d /opt/tomcat tomcat
- Download Tomcat 8 from the official website:
wget https://dlcdn.apache.org/tomcat/tomcat-8/v8.5.84/bin/apache-tomcat-8.5.84.tar.gz
- Create a directory for Tomcat and extract the downloaded file:
mkdir /opt/tomcat tar -xvzf apache-tomcat-8.5.84.tar.gz -C /opt/tomcat/ --strip-components=1
- Set proper ownership for the directory:
chown -R tomcat:tomcat /opt/tomcat
Create a Systemd Service File for Tomcat
To manage the Tomcat service efficiently, you need to create a systemd service file. Follow these steps:
- Create the service file:
nano /etc/systemd/system/tomcat.service
- Add the following lines to the file:
[Unit]
Description=Apache Tomcat Web Application Container
After=network.target
[Service]
Type=forking
Environment=JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64
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
systemctl daemon-reload
- Start the Tomcat service:
systemctl start tomcat
- Verify the status of the Tomcat service:
systemctl status tomcat
Install OpenMRS on Ubuntu 22.04
Now, let’s install OpenMRS on your Ubuntu 22.04 server. Follow these steps:
- Create a directory for OpenMRS and set proper ownership:
mkdir /var/lib/OpenMRS chown -R tomcat:tomcat /var/lib/OpenMRS
- Download the latest version of OpenMRS:
wget https://sourceforge.net/projects/openmrs/files/releases/OpenMRS_Platform_2.5.7/openmrs.war
- Copy the downloaded file to the Tomcat webapps directory:
cp openmrs.war /opt/tomcat/webapps/
- Change the ownership of the openmrs.war file:
chown -R tomcat:tomcat /opt/tomcat/webapps/openmrs.war
Perform OpenMRS Installation via Web Browser
Finally, let’s complete the OpenMRS installation using the web browser:
- Open your web browser and access the OpenMRS installation wizard using the URL http://your-server-ip:8080/openmrs.
- Select your preferred language and click the “=>” button.
- On the Installation Type screen, choose the type of installation you want and click the “=>” button.
- Provide your MySQL root password, note down the admin password, and click the “=>” button.
- 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”.
Congratulations! You have successfully installed OpenMRS on Ubuntu 22.04. You can now leverage this powerful EMR system to store and manage electronic medical records efficiently.
For more information and advanced configurations, refer to the official OpenMRS documentation.
Conclusion
In conclusion, deploying OpenMRS on Ubuntu 22.04 can be a seamless process if you follow the steps outlined in this comprehensive guide. By installing the necessary prerequisites, such as OpenJDK 8, MySQL Server 5.6, and Tomcat 8, you can create a robust environment to support OpenMRS. The web-based installation wizard simplifies the process further, allowing you to configure OpenMRS and start managing electronic medical records with ease.
Remember, when it comes to hosting your OpenMRS instance, reliability and scalability are crucial. Consider partnering with Shape.host, a leading provider of SSD Linux VPS solutions. With their efficient and secure hosting services, you can ensure optimal performance and data protection for your OpenMRS implementation.
So, take the first step towards transforming healthcare delivery with OpenMRS and Shape.host’s reliable hosting solutions.