Development enviornment setup notes/Install script


I wrote a little script to automate building the OpenMRS development environment on a fresh Ubuntu machine. I’ve been using a virtual machine for the ease, safety and consistency. I found Ubuntu 18.04.4 to work the best of all the Linux distributions and versions I tried. I wasn’t certain if this was something that would be helpful or desired but also wanted to mention a couple issues I had when building the project on newer Linux distributions than covered in the getting started wiki. I took relatively detailed notes on the solutions I found and implemented what I found in the script below. I wanted to post and see if any of this might be helpful to add to the wiki. To cursorily mention here:

  1. The mysql-server install of version 5.7 took some extra steps to setup password authentication for the root user on any Ubuntu newer than 16 I tried.
  2. A couple places the getting started documentation says at least java 1.8 is needed but I ran into issues on anything newer than that.
  3. I ran into issues with the Eclipse IDE for Java EE Developers on Ubuntu 18+. I was able to fix some of the package issues but couldn’t resolve problems with plugin support. IntelliJ worked great for me though and the documentations instructions were all good there.
  4. Getting tomcat 8 running was a little tricky for me.

I made a few choices in the script like installing IntelliJ community addition and configurations for the mysql_secure_installation command but I think most is pretty standard and follows what I found in the wiki in terms of recommendations.


echo "Please input a password for your mysql root user:"
echo "(don't forget this you will need it to run the webapp)"
stty -echo
read varpass
stty echo

sudo apt update
sudo apt install mysql-server -y
sudo mysql_secure_installation &> /dev/null << EOT

sudo mysql -e "USE mysql;SELECT User, Host, plugin FROM mysql.user;
UPDATE user SET plugin='mysql_native_password' WHERE User='root';
UPDATE mysql.user SET authentication_string=PASSWORD($quoted_varpass) WHERE User='root';"

sudo systemctl restart mysql

unset varpass
unset quoted_varpass

sudo apt install openjdk-8-jdk -y
sudo apt install git -y
sudo apt install maven -y
sudo apt install curl -y
sudo snap install intellij-idea-community --classic

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

curl -o /tmp/tomcat.tar.gz
sudo tar xzvf /tmp/tomcat.tar.gz -C /opt/tomcat --strip-components=1
cd /opt/tomcat;sudo chgrp -R tomcat /opt/tomcat;sudo chmod -R g+r conf;sudo chmod g+x conf;sudo chown -R tomcat webapps/ work/ temp/ logs/
sudo usermod -aG tomcat $USER

sudo tee -a /etc/systemd/system/tomcat.service > /dev/null <<EOT
Description=Apache Tomcat Web Application Container


Environment='CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC'




cd;git clone
cd openmrs-core; mvn clean install -DskipTests
cd webapp; mvn tomcat:run &
firefox http://localhost:8080/openmrs-webapp


  1. This will fail if another process or program is trying to update the machine. You can check if apt is in use with ‘ps aux | grep -i apt’. You could force any of these processes to stop with ‘sudo killall apt apt-get’ but it would be better just to wait.

  2. MySQL On Ubuntu 16 (maybe earlier?) the mysql installation will allow you to set root pass and password
    authentication without the extra steps in the script.

    Also on newer than Ubuntu 18 the MySQL version is 8 which I believe is not currently supported by OpenMRS. The Ubuntu 18 repositories can be added to the newer versions to install mysql 5.7.

    The script is currently just setup for installing a fresh mysql and will fail if mysql_secure_installation has been run previously.

Some other super basic notes on virtual machine setup:

Virtual box can be downloaded for all platforms here:

Ubuntu 18.04.4 desktop image can be downloaded here: virtual images can speed the process by skipping the OS installation: (Script tested and working on their Ubuntu 18.04.3)

After installing virtual box go to tab ‘Machine’ and select ‘New…’ type Ubuntu for the name and virtual box will automatically match the type and version for you. Select the amount of ram you want to allocate to the machine and click continue. Then create a virtual hard disk, type VDI is fine and I suggest dynamically allocated, so the machine only uses the space it needs. 10gb is more than enough for this purpose. You can then configure your desired settings before starting the machine. Then start the machine and select the .iso image you downloaded and start the machine. Select Install, then Normal installation and I suggest unselecting the download update while installing ubuntu as I’ve found this can lead to issues. Then select erase disk and install ubuntu and continue.

To install guest additions, click tab ‘Devices’ and select ‘Insert Guest Additions CD Image’. Select Run on the popup screen and type your password then turn off the VM after it finishes. Within settings/General/Advanced select shared clipboard bi-directional to enable copy and pasting between machines.

On some versions you will need to run the following command before inserting and running the guest additions:

sudo apt update sudo apt install build-essential dkms linux-headers-$(uname -r)

** The script could also be web hosted and curled to a machine and run with: ‘curl -fsSL https://[…] -o’ ‘sh’ **

Using nano: To run the install script, open an editor in terminal with command ‘nano’ After copy and pasting the script into the file press control + x then y then enter to save the script

Using gedit: Use command ‘gedit’ then paste the script, press save, close the window.

Then command ‘sh’ will run the script. Once completed it will launch the webapp in firefox but you may need wait a but and refresh the page.

This got a little long, thanks for reading!

  • Lars

Thanks @esones0 for sharing! :smile: