Set Up OpenMRS Server with OpenMRS SDK
The OpenMRS SDK (Software Development Kit) is a developer tool built on top of Apache Maven, designed to streamline the development of OpenMRS modules and the OpenMRS Platform itself. It enables rapid setup, configuration, and deployment, allowing developers to run OpenMRS instances quickly without manually managing Tomcat servers or database configurations.
This instruction below applies to linux and with minor adjustments for windows as well.
Prerequisites :
Before setting up OpenMRS , ensure you have the following installed :
Java SE : download
OpenMRS currently supports Java 8 and Java 11 (Java 21 required for main branch)
Verify the installation with:
java -versionIf multiple versions are installed on Linux, select the default one using:
sudo alternatives --config javaand select the versionIf Java SE is not recognized, add below lines in your shell configuration files (eg : .bashrc,.zshrc ) based on the version (here jdk-11 is taken as ref.)
export JAVA_HOME=/usr/lib/jvm/jdk-11.0.29-oracle-x64 export PATH=$JAVA_HOME/bin:$PATH
Apache Maven :
fedora :
sudo dnf install maven -yubuntu :
sudo apt install maven -yverify the installation :
mvn -v
Database :
openmrs supports mysql and postgress (mysql – recommended)
You can either install MySQL directly or run it via Docker (recommended for isolation and easy cleanup).
Docker : download docker desktop
start docker
pull MySQL image
run a MySQL container :
docker run -d --name mysql-container -e MYSQL_ROOT_PASSWORD=pass -p 3306:3306 mysql:latestverify its running : docker ps
If you get errors during this process, try an older version of Docker as described here.
To install Directly:
sudo dnf install mysql-server -ysystemctl start mysqldcheck status :
systemctl status mysqld
Installing OpenMRS SDK
Run the following command to install OpenMRS SDK :
mvn org.openmrs.maven.plugins:openmrs-sdk-maven-plugin:setup-sdkVerify the installation:
mvn openmrs-sdk:help
on successfull , you will get “build success” as ouput
For windows user:
Windows users may also need to swap the SDK over to using TCP instead of HTTP connections. You can expose Docker via TCP (instead of just via HTTP) via Docker Desktop through the following setting:
You'll also need to modify the dockerHost in the SDK properties file (found in C:\Users\“youruser”\openmrs\sdk.properties). Change the "dockerHost=http://127.0.0.1:2375/" line to "dockerHost=tcp://127.0.0.1:2375".
Without this you may encounter the following error: "Unsupported protocol scheme found: 'http://127.0.0.1:2375/". More info here.
Setting Up an OpenMRS Server
run the setup cmd :
mvn openmrs-sdk:setupWhen prompted, enter a server ID (any unique name for your server or press ENTER for default –
remember the name)
Choose 2 for latest O3
select the required version of O3 (select 1 – latest version recommended )
Set up ports:
Default web app port:
8080Remote debug port:
1044
Choose MySQL installation method
Enter 2 if you are using Docker. (recommended)
Note: Make sure you have installed Docker and it is running.
b. Enter 1 if you have installed MySQL directly.
If you choose option 1, you will be prompted to enter the database name and database password .
Select the java version
When the process is complete, the screen displays a “build success” message.
Possible Issues & Fixes:
Port 8080 is already in use
Use a different port when prompted during setup or stop the process in that port
Run OpenMRS Server
(Replace
server1with the server ID you chose.)mvn openmrs-sdk:run -DserverId=server1After sometime you will recieve the following msg :
Open a web browser and navigate to the page and wait patiently it will take some time
After everything is created and updated successfully, the login page will appear
Use the default credentials to log in:
Username:
adminPassword:
Admin123
If you get a CSRF error, edit ~/openmrs/server1/tmp/openmrs/WEB-INF/csrfguard.properties as described here.
Success you have your OpenMRS instance up and running!
Note :
Follow the below steps if you want to run your modified version of any module eg : https://github.com/openmrs/openmrs-module-billing
Fork and clone it the module
mvn clean install for compiling the billing module
copy the .omod file from ../omod/target and paste in /openmrs/{server_name}/modules
start the openmrs instance again
Final thoughts:
Setting up the OpenMRS SDK correctly is the first real step toward contributing effectively to the community.
Once your local environment is up and running, explore the codebase, review open issues, and start with beginner-friendly tickets to build familiarity with the platform’s structure.
You have completed setting up OpenMRS SDK and server. To learn more about OpenMRS SDK go to: OpenMRS SDK, or OpenMRS SDK Step by Step Tutorials.