OpenMRS Installation for Developers on Ubuntu

Ports Used

            OpenMRS Installation requires the use of two ports, 3306 and 8080. Port 3306 is the default port for MySQL and 8080 is the default port for the Jetty server.

            Both ports must be open and have no existing connections. Before going any further, make sure to kill all processes running on those ports with the following commands.

                        fuser -k 3306/tcp

                        fuser -k 8080/tcp



Dependencies

            Before building and compiling OpenMRS make sure you have or install the following dependencies:



Java JRE

            Check for the JRE by going into the Terminal and typing

                        javac –version

            If Java is installed, the result should be 1.6 or higher, and platform 2.x requires Java 1.8.

 


            If you don’t have Java installed, you should get a message returned that says “The program java can be found in the following packages”. Then execute the command:

                        sudo apt-get install default-jre

                       


Java JDK

            Check for the JDK by going into the Terminal and typing

                        java –version

            The result should look something like this:


 

            Again, OpenMRS requires at least java 1.6, and platform 2.x requires Java 1.8.

            If you didn’t have Java installed and you just installed the JDK, execute the command:

                        sudo apt-get install default-jdk


            If you have another version of java installed, please make sure that java 1.8 is set to be the version you are using. Execute

                        sudo update-alternatives --config java

            The result should look something like this:

            Choose java 8 by entering the corresponding selection number.

MySQL

            It is recommended to use MySQL 5.7 for OpenMRS Platform 2.3, or MySQL 5.6 for OpenMRS 2.2 and below. 

            To check if your version of MySQL, type into a terminal:

mysql --version

            In order to install old versions of MySQL on newer versions of Ubuntu (like 20.04), follow the instructions outlined here.

            On older versions of Ubuntu, you may be able to install MySQL using:

sudo apt-get install mysql-server-5.7


           
Once installed, you will then be prompted to set a root password for MySQL.

 

            You must know your MySQL root password, or have a database ready with a username and password for OpenMRS.

            Note: Make sure that your firewall accepts TCP connection on port 3306 for MySQL. Also make sure that your hosts.deny file allows access to your localhost.


Maven

            OpenMRS uses Maven to compile and generate source files. To see if you have maven, use the following command in the Terminal:

                        mvn

            If Maven is not installed, you should get the message “The program ‘mvn’ is currently not installed. You can install it by typing: sudo apt install maven”. Follow those instructions.


Getting the OpenMRS-core from GitHub

To get the source code, follow the instructions on this page:

https://openmrs.atlassian.net/wiki/display/docs/Using+Git

            Make sure you put the openmrs-core into the home directory of your machine.


Downloading a User Interface Module

            Any version after 2.0 does not include a built-in user interface. This means you will need to download one yourself. To download the Legacy UI Module, follow the instructions on this page:  

                         https://openmrs.atlassian.net/wiki/display/docs/User+Interface+Modules


            Then you’ll want to move the legacyui-(version#)-SNAPSHOT.omod into the ~/.OpenMRS/modules directory. If you want to do this manually in the Files window, go to the Home directory and Ctrl+H to find show hidden folders. There should be a “.OpenMRS” folder. Inside that folder there should be a “modules” folder – this is where you want to put the UI .omod file.

 

Compiling the OpenMRS Platform

             In the Terminal, go to the most outer project directory (in this case, inside the openmrs-core directory) and type the command:

                        mvn clean install

            This may take a while depending on your machine. Your Terminal should be looking something like this:


 


            This will compile, run tests, build all artifacts, and install them into your local repository.


Running OpenMRS

            Move into the “webapp” directory inside the “openmrs-core” and run the command:

                        mvn jetty:run

            Wait for “[INFO] Started Jetty Server” which look like this:


 


            Now open a web browser and go to

http://localhost:8080/openmrs

            After it asks you to select a language, you should see this


 


Click here if choosing Advanced Installation Method

Click here if choosing Test Installation Method

If you choose the Simple Installation method, your screen should look like this:



The "Password" field is the password you set when you downloaded MySQL above.  

The default username is admin and the default password is Admin123.  

You can also set whether you want demo data added or not.


Note: If you have created the openmrs database prior to this step, it might be a good idea to choose 'Advanced' installation.