OpenSRP is an open source project that uses multiple platforms.
For a full server build you will need to install the technology components/programs to install OpenSRP.
JDK 1.8 or above (1.8 is recommended)
Development Editor
CouchDB 1.6.1 - port :5984. (Remember to put properties file, bean id and configure in appcontext of spring); /start couchDB
PostgresSQL 10.2 or above (Install as a service since its only used for reporting) - Port: 5432; /start postgres windows service
ActiveMQ 5.4.2 (To stop Exception of JMS for ActiveMQ appearing in console, change in activemq.prop.. tcp:// to vm:// since both are on same server); /start ActiveMQ
Apache-Tomcat 7 or above (Tomcat 7 is recommended)
OpenMRS version 1.12.x or OpenMRS version 2
You will need to Install jdk1.8 to run the application. To do so, first install OpenJDK or Java JDK (both can be used to build OpenSRP however OpenJDK is recommended).
To install OpenJDK run the following commands from terminal:
sudo add-apt-repository ppa:webupd8team/java sudo apt-get update sudo apt-get install openjdk-8-jdk |
First find out the path of your Java Installation
sudo update-alternatives --config java |
It should return something like this:
There are 2 choices for the alternative java (providing /usr/bin/java). Selection Path Priority Status ------------------------------------------------------------ * 0 /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java 1062 auto mode 1 /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java 1061 manual mode 2 /usr/lib/jvm/java-8-oracle/jre/bin/java 1062 manual mode Press enter to keep the current choice[*], or type selection number: |
Copy your installed Java path and put it into file /etc/environment
sudo nano /etc/environment |
Add the following line at the end of the file (Replace YOUR_PATH with your Java path above up to the base directory /usr/lib/jvm/java-8-openjdk-amd64/
There's no need to include /jre/bin/java)
Reload this file
source /etc/environment |
Test it by executing
echo $JAVA_HOME |
If you have set it correctly, your path should now show on screen (ie. /usr/lib/jvm/java-8-openjdk-amd64/)
CouchDB v 1.6.1 is used for data storage. Your package manager may have a different version. In this case, we recommend installing a PPA for the development environment. Production setup may be different. CouchDB 2.x is not supported (v 2.x stopped supporting the PPA as well).
sudo apt-get install software-properties-common sudo add-apt-repository ppa:couchdb/stable sudo apt-get update sudo apt-get install couchdb |
For ubuntu 18.04 use the following installation method
sudo apt-get install curl curl -L https://couchdb.apache.org/repo/bintray-pubkey.asc \ | sudo apt-key add - echo "deb https://apache.bintray.com/couchdb-deb bionic main" \ | sudo tee -a /etc/apt/sources.list.d/apache_couchdb_bionic.list sudo apt-get update sudo apt-get install apache2 couchdb |
Alternatively, follow the CouchDB setup instructions for your environment here.
Install PostgreSQL 10.2 or above.
To install PostgreSQL execute the following commands
sudo apt-get update sudo apt-get install postgresql postgresql-contrib |
Connect to the default database with user postgres
sudo -u postgres psql template1 |
Set the password for user postgres, then exit psql (Ctrl-D)
ALTER USER postgres with encrypted password 'xxxxxxx'; |
Edit the pg_hba.conf
file
sudo vi /etc/postgresql/10.2/main/pg_hba.conf |
And change "peer" to "md5" on the line concerningpostgres
local all postgres peer md5
Restart the database
sudo /etc/init.d/postgresql restart |
Whenpostgresqlservice stops use the command to start
sudo service postgresql start |
We use Apache ActiveMQ for scheduling activities on the server side (JMS, Quartz, Motech, etc.)
Extract the download to /opt
sudo tar -xf apache-activemq-x.x.x-bin.tar.gz -C /opt/ |
To create an ActiveMQ service, create a soft link in init.d using the following command:
sudo ln -snf /opt/apache-activemq-x.x.x/bin/linux-x86-64/activemq /etc/init.d/activemq sudo update-rc.d activemq start 66 3 5 . stop 34 0 1 6 . sudo service activemq start |
Install Maven 2 or above. To install from terminal execute the following command
sudo apt-get install maven |
Install tomcat7 you can download it from tomcat apache site. You can follow this instructions to get it up and running.
sudo apt-get install tomcat7 |
Install mysql using the instructions specified on the mysql documentation for your platform.
For most Debian versions we recommend MySQL 5.6
sudo apt-get install mysql-server-5.6 #If you're using Ubuntu 15.10 or greater sudo apt-get install mysql-server #For those using ubuntu 18.04 and greater, use maria-db instead of Mysql |
If you are using Ubuntu 18.04 or greater, use Maria DB 10.3 is recommended
#install software-properties-common sudo apt-get install software-properties-common #Import gpg key sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8 #add the repo. sudo add-apt-repository 'deb [arch=amd64] http://mirror.zol.co.zw/mariadb/repo/10.3/ubuntu bionic main' #install Maria DB sudo apt update sudo apt -y install mariadb-server mariadb-client #you can select your setting for the next set of instructions |
Create and initialize the quartz database in MySQL as follows
Download this file tables_quartz_mysql.sql
Download the source code and unpack the tarball (https://github.com/rnewson/couchdb-lucene/releases/tag/v1.1.0)
tar -xzf couchdb-lucene-1.1.0.tar.gz -C ~/ |
Enter the directory
cd ~/couchdb-lucene-1.1.0/ |
Build the project with maven
mvn install |
Run maven
mvn |
Unzip the build file and install it in the /opt/ directory
sudo tar -xzf target/couchdb-lucene-1.1.0-dist.tar.gz -C /opt/ |
Rename the distribution folder
sudo mv /opt/couchdb-lucene-1.1.0 /opt/couchdb-lucene |
Edit the local.ini file
sudo nano /opt/couchdb/etc/local.ini |
_fti = {couch_httpd_proxy, handle_proxy_req, <<"http://127.0.0.1:5985">>}
Install necessary tools to compile redis and dowload the latest version of stable redis
#update your repo sudo apt-get update #download a compiler with build essentials sudo apt-get install build-essential #download tcl language sudo apt-get install tcl8.5 #download the latest stable redis wget http://download.redis.io/releases/redis-stable.tar.gz #untar the package tar xzf redis-stable.tar.gz |
Compile and build REDIS Server
#switch to the directory cd redis-stable #elevate your terminal user and type in your password sudo su #run the following tcl commands to compile and install #build make #run tests to ensure there are no errors. Pay attention to any errors shown on screen and resolve make test #install make install |
#Redis comes with default configuration files in the util directory cd utils sudo ./install_server.sh #assuming you used the default options, start redis by using the commands sudo service redis_6379 start sudo service redis_6379 stop #test your redis server by using the command below to start the command line redis-cli #you can quit the cli by typing quit |
Configure automatic startup on boot
sudo update-rc.d redis_6379 defaults |
Secure your new Redis server
# ensure that the server is only bound to local host ip and has a pssword #open the config file using your preferred editor sudo nano /etc/redis/6379.conf #locate the line 'bind 127.0.0.1' if its commented with a hash sign remove it bind 127.0.0.1 # add a password to your redis server. Locate the line '#requirepass foobared' # remove the # and change 'foobared' to your new password requirepass foobared #restart the server and test the new password sudo service redis-server restart |
(Optional) For the development environment install your preferred Java editor Eclipse, STS, NetBeans IDE, IntelliJ IDEA, etc.
STS and IntelliJ IDEA is preferable.
You can download STS (Spring Tools Suite) here
You can download IntelliJ IDEA here
We changed the way we build the server after our refactor and clean up work
After Server Refactor and Cleanup (Recommended)
Checkout Server Web Build on how to build the generic web application
Before Server Refactor and Cleanup
Clone the appropriate OpenSRP Server git repository from https://github.com/OpenSRP/opensrp-server and checkout the correct branch.
git clone https://github.com/OpenSRP/opensrp-server.git git checkout BRANCH_NAME |
Enter the openrsrp-server folder and make sure you're on the correct branch
cd opensrp-server git status |
Run mvn clean install
from the root directory of opensrp-server. If there are test failures, you can run the mvn clean install -Dmaven.test.skip=true to build and install all the different modules.
Once tomcat is running, you can install the opensrp.war file from opensrp-web into the webapps directory in order to run the application.
sudo cp opensrp-web/target/opensrp.war /var/lib/tomcat7/webapps/ |
Open and run the Command prompt as Administrator.
Put in the following lines of code depending on where you placed the Apache ActiveMQ folder.
C:\windows:\system32\cd\ C:\>cd Programs C:\>cd Programs:\apache-activemq-5.15.2-bin C:\>cd Programs:\apache-activemq-5.15.2-bin\cd bin C:\>cd Programs:\apache-activemq-5.15.2-bin\bin\cd win64 C:\>cd Programs:\apache-activemq-5.15.2-bin\bin\win64\InstallService.bat |
Create and initialize the quartz database in MySQL as follows
Download this file tables_quartz_mysql.sql
We changed the way we build the server after our refactor and clean up work
After Server Refactor and Cleanup (Recommended)
Checkout Server Web Build on how to build the generic web application
In the IDE's command line terminal, type in the following command:
mvn clean install |
If the code generates multiples errors, type in the command bellow to build and install all the different modules.
mvn clean install -Dmaven.test.skip=true |
For mac installation more or less will be similar with linux
You will need to Install jdk1.8 to run the application.
Download archive jdk1.8 from https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
If you have multiple jdk installed you can configure your ~/.bash_profile to use jdk1.8. Edit your ~/.bash_profile and add these lines:
export JAVA_7_HOME=$(/usr/libexec/java_home -v1.7) export JAVA_8_HOME=$(/usr/libexec/java_home -v1.8) export JAVA_9_HOME=$(/usr/libexec/java_home -v9) alias java7='export JAVA_HOME=$JAVA_7_HOME' alias java8='export JAVA_HOME=$JAVA_8_HOME' alias java9='export JAVA_HOME=$JAVA_9_HOME' export JAVA_HOME=$JAVA_9_HOME |
Extract apache-couchdb-1.6.1.tar.gz
Go into extraction folder
INSTALL
file:./configure
make
make install
Load your couchdb on startup
sudo launchctl load /Library/LaunchDaemons/org.apache.couchdb.plist |
Install PostgreSQL (source: https://postgresapp.com/)
Open your terminal and run
sudo mkdir -p /etc/paths.d && echo /Applications/Postgres.app/Contents/Versions/latest/bin | sudo tee /etc/paths.d/postgresapp |
Manually access server through terminal command psql
Then create user opensrp
CREATE USER opensrp_admin WITH LOGIN SUPERUSER INHERIT CREATEDB CREATEROLE ENCRYPTED PASSWORD 'admin' NOREPLICATION; |
Then create database opensrp
CREATE DATABASE opensrp WITH OWNER = opensrp_admin ENCODING = 'UTF8' TABLESPACE = pg_default CONNECTION LIMIT = -1; |
Restart PostgreSQL by stop and start from Postgres App
We use Apache ActiveMQ for scheduling activities on the server side (JMS, Quartz, Motech, etc.)
Open your terminal and create folder activemq.
cd /Applications/ && sudo mkdir ActiveMQ |
Extract the download file to /Applications/ActiveMQ
~/.bash_profile
then add line alias activemq="/Applications/ActiveMQ/apache-activemq-5.15.4/bin/activemq"
Install Maven 2 or above.
Download maven from http://maven.apache.org/download.cgi
Open your terminal and create folder Maven.
cd /Applications/ && sudo mkdir Maven |
Extract the download file to /Applications/Maven
~/.bash_profile
then add line export PATH=/Applications/Maven/apache-maven-3.5.3/bin:${PATH}
mvn -version
Install tomcat7
you can download it from http://tomcat.apache.org/. Let say you download Tomcat 8.0.53: https://tomcat.apache.org/download-80.cgi
Open your terminal and create folder Tomcat.
cd /Applications/ && sudo mkdir Tomcat |
Extract the download file to /Applications/Tomcat
Open your ~/.bash_profile
then add line
tomcat(){ if [ $1 ]; then /Applications/Tomcat/apache-tomcat-8.0.53/bin/$1.sh fi } |
Open new terminal and start tomcat by using tomcat startup
tomcat xxxxxxx
Install mysql
You can follow the instruction from https://dev.mysql.com/doc/refman/5.6/en/osx-installation-pkg.html
To make your work easier, you can install mysql workbench from https://dev.mysql.com/doc/workbench/en/wb-installing-mac.html
Create and initialize the quartz database in MySQL as follows
Download this file tables_quartz_mysql.sql
Download the source code and unpack the tarball (https://github.com/rnewson/couchdb-lucene/releases/tag/v1.1.0)
tar -xzf couchdb-lucene-1.1.0.tar.gz -C ~/ |
Enter the directory
cd ~/couchdb-lucene-1.1.0/ |
Build the project with maven
mvn install |
Run maven
mvn |
Unzip the build file and install it in the /opt/ directory
sudo tar -xzf target/couchdb-lucene-1.1.0-dist.tar.gz -C /opt/ |
Rename the distribution folder
sudo mv /opt/couchdb-lucene-1.1.0 /opt/couchdb-lucene |
Edit the local.ini file
sudo nano ~/Library/Preferences/couchdb2-local.ini |
Add the following line
[httpd_global_handlers] _fti = {couch_httpd_proxy, handle_proxy_req, <<"http://127.0.0.1:5985">>} |
~/.bash_profile
then add line alias couchdb-lucene="/opt/couchdb-lucene/bin/run"
Restart couchdb service to fall your change effect executing the command
sudo launchctl stop org.apache.couchdb && sudo launchctl start org.apache.couchdb |
Open new terminal and run couchdb-lucene
(Optional) For the development environment install your preferred Java editor Eclipse, STS, NetBeans IDE, IntelliJ IDEA, etc.
STS and IntelliJ IDEA is preferable.
You can download STS (Spring Tools Suite) here
You can download IntelliJ IDEA here
We changed the way we build the server after our refactor and clean up work
After Server Refactor and Cleanup (Recommended)
Checkout Server Web Build on how to build the generic web application
Clone the appropriate OpenSRP Server git repository from https://github.com/OpenSRP/opensrp-server and checkout the correct branch.
git clone https://github.com/OpenSRP/opensrp-server.git git checkout BRANCH_NAME |
Each implementation of OpenSRP is maintained in a distinct branch on the OpenSRP GitHub repository.
Below is a list of branches to clone:Enter the openrsrp-server folder and make sure you're on the correct branch
cd opensrp-server git status |
Run mvn clean install
from the root directory of opensrp-server. If there are test failures, you can run the mvn clean install -Dmaven.test.skip=true to build and install all the different modules.
Once tomcat is running, you can install the opensrp.war file from opensrp-web into the webapps directory in order to run the application.
sudo cp opensrp-web/target/opensrp.war /Applications/Tomcat/apache-tomcat-x.x.xx/webapps/ |
Proceed to install OpenMRS using the OpenMRS Installation Guide