UbuntuUbuntu Based

How To Install OpenMRS on Ubuntu 24.04 LTS

Install OpenMRS on Ubuntu 24.04

OpenMRS stands as one of the most widely embraced open-source electronic medical record systems globally. Designed to help healthcare facilities manage patient data efficiently, it offers a robust platform supported by an active community of medical professionals, developers, and volunteers. If you plan to run OpenMRS on your own server, Ubuntu 24.04 LTS provides a solid and modern Linux environment that seamlessly integrates with the application’s dependencies. In this guide, discover a comprehensive, step-by-step approach to install OpenMRS on Ubuntu 24.04 LTS, ensuring both performance and security. By following these detailed instructions, system administrators and healthcare IT professionals alike will be able to deploy a stable EMR solution suitable for clinics, hospitals, and research institutions.

A fully functional OpenMRS instance can store, share, and manage patient medical records, serving as a powerful solution for patient data management. This installation process will cover system prerequisites, environment setup, essential software dependencies, database configuration, and user management. Additionally, you will find security best practices, optimization tips, and maintenance guidelines aimed at enhancing reliability. Whether you are looking to set up a small proof-of-concept for your local clinic or a production-ready server for a larger healthcare facility, these steps can be adjusted to match your needs.

Prerequisites

Before deploying OpenMRS, confirm that your server environment meets or surpasses the recommended requirements. Allocating enough memory, CPU capacity, and storage will ensure smooth performance under typical workloads. Below are the key hardware and software prerequisites worth reviewing before proceeding with the installation.

System Requirements

OpenMRS generally performs well on modest hardware, yet it also scales effectively for heavier loads if given enough resources. Since Ubuntu 24.04 LTS is designed to run on modern hardware, please consider the following:

  • CPU: At least 2 GHz multi-core processor (higher performance is recommended if you expect many concurrent users).
  • RAM: A minimum of 2 GB to 4 GB. Larger environments or busy clinics will benefit from 8 GB or more.
  • Storage: 20 GB disk space is workable for small setups; bigger installations will require more, depending on the volume of patient data.
  • Network: Persistent internet connection is crucial for updates, security patches, and community add-ons.

Software Prerequisites

Equally important to having enough hardware resources is ensuring the right software stack is in place. You will need:

  • Ubuntu 24.04 LTS: A fresh or existing installation.
  • Sudo privileges: Required to run system-level commands if not logged in as root.
  • SSH or physical terminal access: Ensures you can configure the server securely and efficiently.

Environment Preparation

To create a stable server environment, it is best to begin with operating system updates and installations of essential dependencies. Regularly updating your server OS helps prevent security vulnerabilities and keeps software packages current. In large healthcare organizations, system administrators typically schedule these updates to minimize disruption. Here is how to get your Ubuntu 24.04 LTS environment ready.

System Updates

Keeping Ubuntu up-to-date is an integral first step. Run the following commands:

sudo apt update
sudo apt upgrade -y

This procedure updates the package lists and upgrades all installed packages. A system reboot may be necessary if the kernel received an update.

Installing Required Dependencies

OpenMRS relies on Java, Tomcat, and a supported SQL database. To keep things simple, many choose MariaDB or MySQL alongside Apache Tomcat. Java powers the application, Tomcat hosts the web interface, and the database engine stores the actual records.

Run these commands to install the basic set of dependencies:

sudo apt install openjdk-8-jdk tomcat8 mariadb-server -y

Although newer versions of Java are available, many production environments recommend Java 8 for maximum compatibility with OpenMRS. Tomcat 8 ensures stable performance for most medium-sized implementations. If your use case demands advanced features from Java or Tomcat, consult the OpenMRS community for guidance on potential compatibility issues.

OpenMRS Installation Process

This section delves into the heart of the setup process, covering database configuration, deployment, and the initial interface configuration. By tailoring each step to your specific environment, you can more precisely match your organization’s security and performance needs. This thorough approach ensures the smooth functioning of OpenMRS from the get-go.

Setting Up the Database

OpenMRS requires a structured repository to store patient information, user accounts, form data, and configuration details. MariaDB or MySQL serve as popular solutions for this purpose. After installing your preferred SQL server package, follow these steps to configure it:

  1. Secure the Installation:
    sudo mysql_secure_installation
    

    During this process, you will set a root password and remove anonymous users, test databases, and remote root logins, thus achieving better security.

  2. Log in to the Database:
    sudo mysql -u root -p
    
  3. Create an OpenMRS Database:
    CREATE DATABASE openmrs_db DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
    
  4. Create a Dedicated User and Set Permissions:
    CREATE USER 'openmrs_user'@'localhost' IDENTIFIED BY 'StrongPasswordHere';
    GRANT ALL PRIVILEGES ON openmrs_db.* TO 'openmrs_user'@'localhost';
    FLUSH PRIVILEGES;
    EXIT;
    

    Remember to replace StrongPasswordHere with a secure password that conforms to best practices. This approach ensures that only the openmrs_user account can access the openmrs_db database, limiting unwarranted exposure.

Deploying OpenMRS

With your database up and running, the next step is to fetch the OpenMRS WAR file, deploy it onto Tomcat, then configure the initial setup wizard. Generally, the steps involve creating a dedicated directory for OpenMRS, adjusting permissions, and making sure Tomcat recognizes the deployed application.

  1. Create a Directory for OpenMRS:
    sudo mkdir /usr/share/tomcat8/.OpenMRS
    sudo chown -R tomcat:tomcat /usr/share/tomcat8/.OpenMRS
    

    Make sure to adjust ownership so that Tomcat can read and write within this directory. Without proper permissions, the application setup may fail or freeze.

  2. Download the OpenMRS WAR File:
    Visit the official OpenMRS website to locate the latest stable WAR release. Download the file using wget or curl:

    wget https://sourceforge.net/projects/openmrs/files/releases/OpenMRS_Platform_2.x.x.war -O openmrs.war
    

    Be sure to replace the URL with the correct version number for the release you plan to install.

  3. Deploy the WAR File to Tomcat:
    sudo mv openmrs.war /var/lib/tomcat8/webapps/
    sudo systemctl restart tomcat8
    

    This action automatically expands the WAR file in the webapps directory. After the Tomcat service restarts, OpenMRS files become available under /var/lib/tomcat8/webapps/openmrs.

Running the OpenMRS Setup Wizard

After deploying OpenMRS, you can use the convenient setup wizard via a web browser. Follow these steps:

  1. Navigate to the OpenMRS URL: Open your favorite web browser and go to:
    http://server-ip-or-domain:8080/openmrs
    
  2. Choose Database Updates: The wizard prompts you for database credentials. Provide openmrs_db for the database name, openmrs_user for the username, and the strong password created earlier.
  3. Initial Setup: The wizard populates the necessary tables in the database, configures sample data if you choose to include a demo set, and guides you through specifying general settings.
  4. Create an Administrator Account: You will be prompted to define administrative credentials. Choose a secure username and password, as this grants management access to patient records, modules, system settings, and more.

Install OpenMRS on Ubuntu 24.04 LTS

Upon completion, you will see a login interface for OpenMRS, marking the end of the main installation process and the beginning of your server’s operational phase.

Post-Installation Steps

Securing and optimizing an EMR system is a critical concern for healthcare institutions hoping to maintain compliance with various data protection standards. After the basic set up, concentrate on access control, data encryption, server hardening, and fine-tuning the database engine for better performance.

Security Configuration

Medical data is highly sensitive, so it is paramount to implement strong security measures. Start by changing any default Tomcat credentials and restricting access to the Tomcat management interface if you installed additional Tomcat management packages. Then proceed with the following steps:

  • Enable UFW (Uncomplicated Firewall):
    sudo ufw enable
    sudo ufw allow ssh
    sudo ufw allow 8080/tcp
    

    Restrict other ports as needed. Only keep open the services you plan to use.

  • Enable SSL/TLS: Serve your OpenMRS instance using HTTPS for encrypted client-server communications. You can employ an existing certificate, create a self-signed certificate for testing, or secure one from a recognized certificate authority.
  • Update System Packages: Continue to apply security patches:
    sudo apt update && sudo apt upgrade -y
    

    Keep your server regularly patched to close newly discovered vulnerabilities.

Performance Optimization

Healthcare data often grows fast, meaning performance optimization is essential to ensure swift data retrieval. Consider the following enhancements:

  • Java Memory Allocation: Increase Tomcat’s memory usage limits by editing /etc/default/tomcat8. For instance:
    JAVA_OPTS="-Xms512m -Xmx1024m ..."
    

    Choose memory allocations based on your server’s capacity and the anticipated number of concurrent users.

  • Optimize the Database Engine: Within MariaDB or MySQL, consider fine-tuning innodb_buffer_pool_size and query_cache_size (if relevant). For heavier loads, also optimize table indexes to handle frequent queries more efficiently.
  • Tomcat Thread Pool: Adjust the maxThreads parameter in the /etc/tomcat8/server.xml file to match projected network traffic.

Verification and Testing

Once you have configured your system, it is prudent to test each component to confirm that everything is working as intended. A thorough testing regimen can detect any oversights before they become serious issues in a production environment.

System Status Checks

Begin by confirming that Tomcat and MariaDB are both active:

sudo systemctl status tomcat8
sudo systemctl status mariadb

If you discover that a service is not active, a quick look at the system logs may provide a clue. For instance, you can use journalctl -u tomcat8 or journalctl -u mariadb to find relevant error messages.

Application Functionality Testing

  1. Browser-based Login: Open the login page again and verify that you can authenticate with your administrative credentials. Successful login indicates that the OpenMRS backend and your database are effectively communicating.
  2. Create Demo Patients: Inside OpenMRS, create a sample patient record. This verifies that data is being correctly written to the openmrs_db database.
  3. Check Logs: Examine the Tomcat logs, typically found in /var/log/tomcat8/, for any error messages or warnings that might signal configuration issues.

Common Troubleshooting Tips

When issues arise, consider these solutions:

  • Database Connection Errors: Verify that the correct username, password, and database name are specified in the OpenMRS configuration. Confirm that your MariaDB service is running. Typos or incorrect credentials can break connectivity.
  • Permission Issues: If you encounter file or folder permission errors, adjust ownership for the Tomcat user. Thoroughly verify that your Tomcat user has read and write access to /usr/share/tomcat8/.OpenMRS or the /var/lib/tomcat8/webapps/ directory.
  • Port Conflicts: If port 8080 is already in use, reconfigure Tomcat’s server.xml to utilize a free port or terminate the conflicting service. Reviewing the logs for “Port already in use” errors can point you in the right direction.
  • Long Startup Times: View Tomcat logs. Large log outputs about memory constraints can indicate the need for more heap space via -Xmx or -Xms options in JAVA_OPTS.

Maintenance and Updates

Running a healthcare software solution means adopting an ongoing maintenance strategy. Keeping OpenMRS and its dependencies updated not only guards against security threats but also enhances performance and ensures new features are supported. Below are best practices for maintaining a smooth and secure environment on Ubuntu 24.04 LTS.

Backup Procedures

Maintaining patient data integrity and ensuring data availability in case of hardware or software failure is paramount for any healthcare entity. Frequent backups are the best safeguard against data loss. Here is a quick snapshot of typical backup steps:

  1. Database Dumps:
    mysqldump -u openmrs_user -p openmrs_db > /backups/openmrs_db_$(date +%F).sql
    

    Save these on separate storage, perhaps in a secured remote server or a cloud backup to guarantee redundancy.

  2. OpenMRS Folder Backup: Zip up or rsync the .OpenMRS folder under /usr/share/tomcat8 to preserve your configurations and modules.
  3. Automation: Combine these steps into a scheduled cron job for daily or weekly backups, ensuring minimal manual intervention.

Scheduled Updates

Keeping OpenMRS modules, core software, and the underlying Linux environment up to date is vital. Perform regularly scheduled updates to avoid vulnerabilities. Here are recommended tasks:

  • Ubuntu Updates:
    sudo apt update
    sudo apt upgrade -y
    
  • OpenMRS Module and Core Updates: Check the OpenMRS Addon Index or the official website for newly released modules or patches. Some administrators prefer to test updates on a staging environment before rolling them out to production.

System Monitoring

Tracking resource usage (CPU, RAM, storage, and network activity) gives early warnings of potential bottlenecks. Tools such as htop, vmstat, and iostat help in real-time server monitoring. Expand your monitoring with system resource graphs, and consider solutions like Nagios, Zabbix, or Prometheus with Grafana for comprehensive alerts and visual insights.

Congratulations! You have successfully installed OpenMRS. Thanks for using this tutorial for installing OpenMRS (Open Medical Record System) on Ubuntu 24.04 LTS system. For additional help or useful information, we recommend you check the OpenMRS website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.
Back to top button