OpenSRP is an open source project that uses multiple platforms.
...
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:
Code Block language bash sudo add-apt-repository ppa:webupd8team/java sudo apt-get update sudo apt-get install openjdk-8-jdk
- After installing Java, set the JAVA_HOME variable - you will need this later in the set up so be sure to set it correctly.
First find out the path of your Java Installation
Code Block language bash sudo update-alternatives --config java
It should return something like this:No Format nopanel true 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
Code Block language bash 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
JAVA_HOME="YOUR _PATH"/usr/lib/jvm/java-8-openjdk-amd64/
There's no need to include /jre/bin/java)Reload this file
Code Block language bash source /etc/environment
Test it by executing
Code Block language bash 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).
Code Block language bash 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
Code Block language bash 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.
(Optional) The OpenSRP reporting module and ETL process uses Install PostgreSQL 9.1 or above.
To install PostgreSQL execute the following commands
Code Block language bash sudo apt-get update sudo apt-get install postgresql postgresql-contrib
Connect to the default database with user postgres
Code Block language bash sudo -u postgres psql template1
Set the password for user postgres, then exit psql (Ctrl-D)
Code Block language bash ALTER USER postgres with encrypted password 'xxxxxxx';
Edit the
pg_hba.conf
fileCode Block language bash sudo vi /etc/postgresql/9.1/main/pg_hba.conf
And change "peer" to "md5" on the line concerningpostgres
local all postgrespeermd5Restart the database
Code Block language bash sudo /etc/init.d/postgresql restart
Whenpostgresqlservice stops use the command to start
Code Block language bash sudo service postgresql start
We use Apache ActiveMQ for scheduling activities on the server side (JMS, Quartz, Motech, etc.)
- To install Apache ActiveMQ download the latest stable release from Apache ActiveMQ Site
Extract the download to /opt
Code Block language bash 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:
Code Block language bash 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
- Verify it's running by checking the following url:
http://localhost:8161/
Install Maven 2 or above. To install from terminal execute the following command
Code Block language bash 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.
Code Block language bash 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
Code Block language bash 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
Code Block language bash #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
- Create the quartz database by running: CREATE DATABASE motechquartz; Ensure that the user you created has permission to this database.
- (Optional) Create a user for quartz that only has access to the motechquartz database
- To create the database tables for the motechquartz database: mysql -u root -p"$MYSQL_ROOT_PASSWORD" "motechquartz" < "$PATH_TO"/tables_quartz_mysql.sql
- Install CouchDB Lucene v1.1
Download the source code and unpack the tarball (https://github.com/rnewson/couchdb-lucene/releases/tag/v1.1.0)
Code Block language bash tar -xzf couchdb-lucene-1.1.0.tar.gz -C ~/
Enter the directory
Code Block language bash cd ~/couchdb-lucene-1.1.0/
Build the project with maven
Code Block language bash mvn install
Run maven
Code Block language bash mvn
Unzip the build file and install it in the /opt/ directory
Code Block language bash sudo tar -xzf target/couchdb-lucene-1.1.0-dist.tar.gz -C /opt/
Rename the distribution folder
Code Block language bash sudo mv /opt/couchdb-lucene-1.1.0 /opt/couchdb-lucene
- Configure CouchDB to work with Lucene
Edit the local.ini file
Code Block language bash sudo nano /opt/couchdb/etc/local.ini
- Add the following line under the [httpd_global_handlers]
_fti = {couch_httpd_proxy, handle_proxy_req, <<"http://127.0.0.1:5985">>}
- Enter into directory by the command cd /opt/couchdb-lucene/tools/etc/init.d/couchdb-lucene/
- Edit the couchdb-lucene file as DAEMON=/opt/couchdb-lucene/bin/run for your application directory path.
- If you have set your admin user in couchdb Navigate to /opt/couchdb-lucene/conf/ then Edit the couchdb-lucene.ini and edit the last code url = http://localhost:5984/ with url = http://youradminuser:youradminpass@localhost:5984/
- Navigate to /opt/couchdb-lucene/tools/etc/init.d/couchdb-lucene/
- After saving run the command in the terminal cp couchdb-lucene /etc/init.d/
- Restart couchdb service to fall your change effect executing the command sudo service couchdb restart
- Start the couchdb-lucene service executing the command sudo service couchdb-lucene start to create the Channel with couchdb server
- Installing Redis
Install necessary tools to compile redis and dowload the latest version of stable redis
Code Block language bash #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
Code Block language bash #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
- Run Configuration of Redis, you can use the default options if you like
Code Block language bash #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
Code Block language bash sudo update-rc.d redis_6379 defaults
Secure your new Redis server
Code Block language bash # 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 hereWe 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
- Checkout OpenSRP Server Refactor and Clean up for more information
Before Server Refactor and Cleanup
Clone the appropriate OpenSRP Server git repository from https://github.com/OpenSRP/opensrp-server and checkout the correct branch.
Code Block language bash 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:- Zambia Electronic Immunization - Branch Name: "path"
- TB Reach applicatoin - Branch Name: "tb-reach"
- mCare - Branch Name: "mcare-2"
- Bangladesh - Branch Name: "bd-family-planning"
- Indonesia - Branch Name: "indonesia-server-v2"
- (Optional) Import the git repository into your IDE
- Update the following files with password credentials (MySQL, PostgreSQL and CouchDB)
- assets/config/couchdb.properties
- assets/config/opensrp.properties
- opensrp-web/src/main/resources/quartz.properties
- opensrp-web/src/main/webapp/META-INF/context.xml
- assets/migrations/environments/development.properties
- Build the OpenSRP WAR file in your IDE or maven
- If using maven:
Enter the openrsrp-server folder and make sure you're on the correct branch
Code Block 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.
- If using maven:
Once tomcat is running, you can install the opensrp.war file from opensrp-web into the webapps directory in order to run the application.
Code Block language bash sudo cp opensrp-web/target/opensrp.war /var/lib/tomcat7/webapps/
- Proceed to install OpenMRS using the OpenMRS Installation Guide
...
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
- Chose Mac OS X x64 to download
- After download finished, double click the dmg file and continue with the installation
If you have multiple jdk installed you can configure your ~/.bash_profile to use jdk1.8. Edit your ~/.bash_profile and add these lines:
Code Block language bash 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
- 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).
- Install erlang if you dont have erlang installed, download it from https://packages.erlang-solutions.com/os-x-installer/ErlangInstaller0.9.1.dmg
- Download CouchDB 1.6.1 from https://archive.apache.org/dist/couchdb/source/1.6.1/apache-couchdb-1.6.1.tar.gz
Extract apache-couchdb-1.6.1.tar.gz
Go into extraction folder
- Follow instruction on
INSTALL
file:- Run command line
./configure
- Run command line
make
- Run command line
make install
- Run command line
Load your couchdb on startup
Code Block language bash sudo launchctl load /Library/LaunchDaemons/org.apache.couchdb.plist
Install PostgreSQL (source: https://postgresapp.com/)
- Download PostgreSQL app from https://postgresapp.com/ (exp: https://github.com/PostgresApp/PostgresApp/releases/download/v2.1.4/Postgres-2.1.4.dmg)
- Execute the dmg file
- Go to your launch pad and run Postgres App
- Run the server from Postgres App
Open your terminal and run
Code Block language bash 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
Code Block language bash CREATE USER opensrp_admin WITH LOGIN SUPERUSER INHERIT CREATEDB CREATEROLE ENCRYPTED PASSWORD 'admin' NOREPLICATION;
Then create database opensrp
Code Block language bash 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.)
- To install Apache ActiveMQ download the latest stable release from http://activemq.apache.org/download.html
Open your terminal and create folder activemq.
Code Block language bash cd /Applications/ && sudo mkdir ActiveMQ
Extract the download file to /Applications/ActiveMQ
- Open your
~/.bash_profile
then add linealias activemq="/Applications/ActiveMQ/apache-activemq-5.15.4/bin/activemq"
- Open new terminal and start your activemq server activemq start
- Verify it's running by checking the following url:
http://localhost:8161/
Install Maven 2 or above.
Download maven from http://maven.apache.org/download.cgi
Open your terminal and create folder Maven.
Code Block language bash cd /Applications/ && sudo mkdir Maven
Extract the download file to /Applications/Maven
- Open your
~/.bash_profile
then add lineexport PATH=/Applications/Maven/apache-maven-3.5.3/bin:${PATH}
- Open new terminal and see if your maven installed
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.
Code Block language bash cd /Applications/ && sudo mkdir Tomcat
Extract the download file to /Applications/Tomcat
Open your
~/.bash_profile
then add lineCode Block language bash 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
- You can run sh file inside /Applications/Tomcat/apache-tomcat-8.0.53/bin/ by using command
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
- Create the quartz database by running: CREATE DATABASE motechquartz; Ensure that the user you created has permission to this database.
- (Optional) Create a user for quartz that only has access to the motechquartz database
- To create the database tables for the motechquartz database: mysql -u root -p"$MYSQL_ROOT_PASSWORD" "motechquartz" < "$PATH_TO"/tables_quartz_mysql.sql
- Install CouchDB Lucene v1.1 (https://github.com/rnewson/couchdb-lucene)
Download the source code and unpack the tarball (https://github.com/rnewson/couchdb-lucene/releases/tag/v1.1.0)
Code Block language bash tar -xzf couchdb-lucene-1.1.0.tar.gz -C ~/
Enter the directory
Code Block language bash cd ~/couchdb-lucene-1.1.0/
Build the project with maven
Code Block language bash mvn install
Run maven
Code Block language bash mvn
Unzip the build file and install it in the /opt/ directory
Code Block language bash sudo tar -xzf target/couchdb-lucene-1.1.0-dist.tar.gz -C /opt/
Rename the distribution folder
Code Block language bash sudo mv /opt/couchdb-lucene-1.1.0 /opt/couchdb-lucene
- Configure CouchDB to work with Lucene
Edit the local.ini file
Code Block language bash sudo nano ~/Library/Preferences/couchdb2-local.ini
Add the following line
Code Block language bash [httpd_global_handlers] _fti = {couch_httpd_proxy, handle_proxy_req, <<"http://127.0.0.1:5985">>}
- Open your
~/.bash_profile
then add line aliascouchdb-lucene="/opt/couchdb-lucene/bin/run"
- If you have set your admin user in couchdb Navigate to /opt/couchdb-lucene/conf/ then Edit the couchdb-lucene.ini and edit the last code url = http://localhost:5984/ with url = http://youradminuser:youradminpass@localhost:5984/
Restart couchdb service to fall your change effect executing the command
Code Block language bash 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 hereWe 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
- Checkout OpenSRP Server Refactor and Clean up for more information
- Before Server Refactor and Cleanup
Clone the appropriate OpenSRP Server git repository from https://github.com/OpenSRP/opensrp-server and checkout the correct branch.
Code Block language bash 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:- Zambia Electronic Immunization - Branch Name: "path"
- TB Reach applicatoin - Branch Name: "tb-reach"
- mCare - Branch Name: "mcare-2"
- Bangladesh - Branch Name: "bd-family-planning"
- Indonesia - Branch Name: "indonesia-server-v2"
- (Optional) Import the git repository into your IDE
- Update the following files with password credentials (MySQL, PostgreSQL and CouchDB)
- assets/config/couchdb.properties
- assets/config/opensrp.properties
- opensrp-web/src/main/resources/quartz.properties
- opensrp-web/src/main/webapp/META-INF/context.xml PostgreSQL credentials
- assets/migrations/environments/development.properties PostgreSQL credentials
- Build the OpenSRP WAR file in your IDE or maven
- If using maven:
Enter the openrsrp-server folder and make sure you're on the correct branch
Code Block 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.
- If using maven:
Once tomcat is running, you can install the opensrp.war file from opensrp-web into the webapps directory in order to run the application.
Code Block language bash sudo cp opensrp-web/target/opensrp.war /Applications/Tomcat/apache-tomcat-x.x.xx/webapps/
Proceed to install OpenMRS using the OpenMRS Installation Guide