Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Remove the word Optional in front of postgres for the linux install

OpenSRP is an open source project that uses multiple platforms.  

...

  1. 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).

    1. To install OpenJDK run the following commands from terminal:

      Code Block
      languagebash
      sudo add-apt-repository ppa:webupd8team/java
      sudo apt-get update   
      sudo apt-get install openjdk-8-jdk


    2. After installing Java, set the JAVA_HOME variable - you will need this later in the set up so be sure to set it correctly.
      1. First find out the path of your Java Installation

        Code Block
        languagebash
        sudo update-alternatives --config java


        It should return something like this:

        No Format
        nopaneltrue
        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:


      2. Copy your installed Java path and put it into file /etc/environment

        Code Block
        languagebash
        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) 

        JAVA_HOME="YOUR _PATH"

      3. Reload this file

        Code Block
        languagebash
        source /etc/environment

        Test it by executing

        Code Block
        languagebash
        echo $JAVA_HOME

        If you have set it correctly, your path should now show on screen (ie. /usr/lib/jvm/java-8-openjdk-amd64/)

  2. 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
    languagebash
    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
    languagebash
    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.

  3. (Optional) The OpenSRP reporting module and ETL process uses Install PostgreSQL 9.1 or above.

    1. To install PostgreSQL execute the following commands

      Code Block
      languagebash
      sudo apt-get update
      sudo apt-get install postgresql postgresql-contrib


    2. Connect to the default database with user postgres

      Code Block
      languagebash
      sudo -u postgres psql template1


    3. Set the password for user postgres, then exit psql (Ctrl-D)

      Code Block
      languagebash
      ALTER USER postgres with encrypted password 'xxxxxxx';


    4. Edit the pg_hba.conf file

      Code Block
      languagebash
      sudo vi /etc/postgresql/9.1/main/pg_hba.conf


    5. And change "peer" to "md5" on the line concerningpostgres
      local all postgres peer md5

    6. Restart the database

      Code Block
      languagebash
      sudo /etc/init.d/postgresql restart


    7. Whenpostgresqlservice stops use the command to start

      Code Block
      languagebash
      sudo service postgresql start


  4. We use Apache ActiveMQ for scheduling activities on the server side (JMS, Quartz, Motech, etc.)

    1. To install Apache ActiveMQ download the latest stable release from Apache ActiveMQ Site 
    2. Extract the download to /opt

      Code Block
      languagebash
      sudo tar -xf apache-activemq-x.x.x-bin.tar.gz -C /opt/


    3. To create an ActiveMQ service, create a soft link in init.d using the following command:

      Code Block
      languagebash
      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


    4. Verify it's running by checking the following url:
      http://localhost:8161/
  5. Install Maven 2 or above. To install from terminal execute the following command

    Code Block
    languagebash
    sudo apt-get install maven


  6. Install tomcat7 you can download it from tomcat apache site. You can follow this instructions to get it up and running.

    Code Block
    languagebash
    sudo apt-get install tomcat7


  7. Install mysql using the instructions specified on the mysql documentation for your platform.

    1. For most Debian versions we recommend MySQL 5.6

      Code Block
      languagebash
      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


    2. If you are using Ubuntu 18.04 or greater, use Maria DB 10.3 is recommended

      Code Block
      languagebash
      #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


  8. Create and initialize the quartz database in MySQL as follows

    1. Download this file tables_quartz_mysql.sql

    2. Create the quartz database by running: CREATE DATABASE motechquartz; Ensure that the user you created has permission to this database.
    3. (Optional) Create a user for quartz that only has access to the motechquartz database
    4. To create the database tables for the motechquartz database: mysql -u root -p"$MYSQL_ROOT_PASSWORD" "motechquartz" < "$PATH_TO"/tables_quartz_mysql.sql
  9. Install CouchDB Lucene v1.1
    1. Download the source code and unpack the tarball (https://github.com/rnewson/couchdb-lucene/releases/tag/v1.1.0)

      Code Block
      languagebash
      tar -xzf couchdb-lucene-1.1.0.tar.gz -C ~/


    2. Enter the directory

      Code Block
      languagebash
      cd ~/couchdb-lucene-1.1.0/


    3. Build the project with maven

      Code Block
      languagebash
      mvn install


    4. Run maven

      Code Block
      languagebash
      mvn


    5. Unzip the build file and install it in the /opt/ directory

      Code Block
      languagebash
      sudo tar -xzf target/couchdb-lucene-1.1.0-dist.tar.gz -C /opt/


    6. Rename the distribution folder

      Code Block
      languagebash
      sudo mv /opt/couchdb-lucene-1.1.0 /opt/couchdb-lucene


  10. Configure CouchDB to work with Lucene
    1. Edit the local.ini file

      Code Block
      languagebash
      sudo nano /opt/couchdb/etc/local.ini


    2. Add the following line under the [httpd_global_handlers]
      _fti = {couch_httpd_proxy, handle_proxy_req, <<"http://127.0.0.1:5985">>}
    3. Enter into directory by the command  cd /opt/couchdb-lucene/tools/etc/init.d/couchdb-lucene/
    4. Edit the couchdb-lucene file as DAEMON=/opt/couchdb-lucene/bin/run for your application directory path.
    5. 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/
    6. Navigate to /opt/couchdb-lucene/tools/etc/init.d/couchdb-lucene/
    7. After saving run the command in the terminal cp couchdb-lucene /etc/init.d/
    8. Restart couchdb service to fall your change effect executing the command sudo service couchdb restart
    9. Start the couchdb-lucene service executing the command sudo service couchdb-lucene start to create the Channel with couchdb server
  11. Installing Redis
    1. Install necessary tools to compile redis and dowload the latest version of stable redis 

      Code Block
      languagebash
      #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
      


    2. Compile and build REDIS Server

      Code Block
      languagebash
      #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


    3. Run Configuration of Redis, you can use the default options if you like


      Code Block
      languagebash
      #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


    4. Configure automatic startup on boot

      Code Block
      languagebash
      sudo update-rc.d redis_6379 defaults


    5. Secure your new Redis server

      Code Block
      languagebash
      # 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


  12. (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

  13. We changed the way we build the server after our refactor and clean up work

    1. After Server Refactor and Cleanup (Recommended)

      1. Checkout Server Web Build on how to build the generic web application

      2. Checkout OpenSRP Server Refactor and Clean up for more information
    2. Before Server Refactor and Cleanup

      1. Clone the appropriate OpenSRP Server git repository from https://github.com/OpenSRP/opensrp-server and checkout the correct branch.


        Code Block
        languagebash
        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:
        1. Zambia Electronic Immunization - Branch Name: "path"
        2. TB Reach applicatoin - Branch Name: "tb-reach"
        3. mCare - Branch Name: "mcare-2"
        4. Bangladesh - Branch Name: "bd-family-planning"
        5. Indonesia - Branch Name: "indonesia-server-v2"
      2. (Optional) Import the git repository into your IDE
      3. Update the following files with password credentials (MySQL, PostgreSQL and CouchDB)
        1. assets/config/couchdb.properties
        2. assets/config/opensrp.properties
        3. opensrp-web/src/main/resources/quartz.properties
        4. opensrp-web/src/main/webapp/META-INF/context.xml
        5. assets/migrations/environments/development.properties
      4. Build the OpenSRP WAR file in your IDE or maven
        1. If using maven:
          1. Enter the openrsrp-server folder and make sure you're on the correct branch 

            Code Block
            cd opensrp-server
            git status


          2. 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.

      5. 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
        languagebash
        sudo cp opensrp-web/target/opensrp.war /var/lib/tomcat7/webapps/


  14. Proceed to install OpenMRS using the OpenMRS Installation Guide

...

  1. You will need to Install jdk1.8 to run the application.

    1. Download archive jdk1.8 from https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

    2. Chose Mac OS X x64 to download 
    3. After download finished, double click the dmg file and continue with the installation
    4. 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
      languagebash
      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


  2. 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). 
    1. Install erlang if you dont have erlang installed, download it from https://packages.erlang-solutions.com/os-x-installer/ErlangInstaller0.9.1.dmg
    2. Download CouchDB 1.6.1 from https://archive.apache.org/dist/couchdb/source/1.6.1/apache-couchdb-1.6.1.tar.gz
    3. Extract  apache-couchdb-1.6.1.tar.gz

    4. Go into extraction folder 

    5. Follow instruction on INSTALL file:
      1. Run command line ./configure
      2. Run command line make
      3. Run command line make install
    6. Load your couchdb on startup

      Code Block
      languagebash
      sudo launchctl load /Library/LaunchDaemons/org.apache.couchdb.plist


  3. Install PostgreSQL (source: https://postgresapp.com/)

    1. Download PostgreSQL app from https://postgresapp.com/ (exp: https://github.com/PostgresApp/PostgresApp/releases/download/v2.1.4/Postgres-2.1.4.dmg)
    2. Execute the dmg file
    3. Go to your launch pad and run Postgres App
    4. Run the server from Postgres App
    5. Open your terminal and run

      Code Block
      languagebash
      sudo mkdir -p /etc/paths.d && echo /Applications/Postgres.app/Contents/Versions/latest/bin | sudo tee /etc/paths.d/postgresapp


    6. Manually access server through terminal command psql

    7. Then create user opensrp

      Code Block
      languagebash
      CREATE USER opensrp_admin WITH
        LOGIN
        SUPERUSER
        INHERIT
        CREATEDB
        CREATEROLE
        ENCRYPTED PASSWORD 'admin'
        NOREPLICATION;


    8. Then create database opensrp

      Code Block
      languagebash
      CREATE DATABASE opensrp
          WITH 
          OWNER = opensrp_admin
          ENCODING = 'UTF8'
          TABLESPACE = pg_default
          CONNECTION LIMIT = -1;


    9. Restart PostgreSQL by stop and start from Postgres App

  4. We use Apache ActiveMQ for scheduling activities on the server side (JMS, Quartz, Motech, etc.)

    1. To install Apache ActiveMQ download the latest stable release from http://activemq.apache.org/download.html
    2. Open your terminal and create folder activemq.

      Code Block
      languagebash
      cd /Applications/ && sudo mkdir ActiveMQ


    3. Extract the download file to /Applications/ActiveMQ

    4. Open your ~/.bash_profile then add line alias activemq="/Applications/ActiveMQ/apache-activemq-5.15.4/bin/activemq"
    5. Open new terminal and start your activemq server activemq start
    6. Verify it's running by checking the following url:
      http://localhost:8161/
  5. Install Maven 2 or above.

    1. Download maven from http://maven.apache.org/download.cgi

    2. Open your terminal and create folder Maven.

      Code Block
      languagebash
      cd /Applications/ && sudo mkdir Maven


    3. Extract the download file to /Applications/Maven

    4. Open your ~/.bash_profile then add line export PATH=/Applications/Maven/apache-maven-3.5.3/bin:${PATH}
    5. Open new terminal and see if your maven installed mvn -version
  6. Install tomcat7

    1. you can download it from http://tomcat.apache.org/. Let say you download Tomcat 8.0.53: https://tomcat.apache.org/download-80.cgi

    2. Open your terminal and create folder Tomcat.

      Code Block
      languagebash
      cd /Applications/ && sudo mkdir Tomcat


    3. Extract the download file to /Applications/Tomcat

    4. Open your ~/.bash_profile then add line 

      Code Block
      languagebash
      tomcat(){
              if [ $1 ]; then
                      /Applications/Tomcat/apache-tomcat-8.0.53/bin/$1.sh
              fi
      }


    5. Open new terminal and start tomcat by using tomcat startup

    6. You can run sh file inside /Applications/Tomcat/apache-tomcat-8.0.53/bin/ by using command tomcat xxxxxxx
  7. Install mysql

    1. You can follow the instruction from https://dev.mysql.com/doc/refman/5.6/en/osx-installation-pkg.html

    2. To make your work easier, you can install mysql workbench from https://dev.mysql.com/doc/workbench/en/wb-installing-mac.html

  8. Create and initialize the quartz database in MySQL as follows

    1. Download this file tables_quartz_mysql.sql

    2. Create the quartz database by running: CREATE DATABASE motechquartz; Ensure that the user you created has permission to this database.
    3. (Optional) Create a user for quartz that only has access to the motechquartz database
    4. To create the database tables for the motechquartz database: mysql -u root -p"$MYSQL_ROOT_PASSWORD" "motechquartz" < "$PATH_TO"/tables_quartz_mysql.sql
  9. Install CouchDB Lucene v1.1 (https://github.com/rnewson/couchdb-lucene)
    1. Download the source code and unpack the tarball (https://github.com/rnewson/couchdb-lucene/releases/tag/v1.1.0)

      Code Block
      languagebash
      tar -xzf couchdb-lucene-1.1.0.tar.gz -C ~/


    2. Enter the directory

      Code Block
      languagebash
      cd ~/couchdb-lucene-1.1.0/


    3. Build the project with maven

      Code Block
      languagebash
      mvn install


    4. Run maven

      Code Block
      languagebash
      mvn


    5. Unzip the build file and install it in the /opt/ directory

      Code Block
      languagebash
      sudo tar -xzf target/couchdb-lucene-1.1.0-dist.tar.gz -C /opt/


    6. Rename the distribution folder

      Code Block
      languagebash
      sudo mv /opt/couchdb-lucene-1.1.0 /opt/couchdb-lucene


  10. Configure CouchDB to work with Lucene
    1. Edit the local.ini file

      Code Block
      languagebash
      sudo nano ~/Library/Preferences/couchdb2-local.ini


    2. Add the following line

      Code Block
      languagebash
      [httpd_global_handlers]
      _fti = {couch_httpd_proxy, handle_proxy_req, <<"http://127.0.0.1:5985">>}


    3. Open your ~/.bash_profile then add line alias couchdb-lucene="/opt/couchdb-lucene/bin/run"
    4. 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/
    5. Restart couchdb service to fall your change effect executing the command 

      Code Block
      languagebash
      sudo launchctl stop org.apache.couchdb &&
      sudo launchctl start org.apache.couchdb


    6. Open new terminal and run couchdb-lucene

  11. (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

  12. We changed the way we build the server after our refactor and clean up work

    1. After Server Refactor and Cleanup (Recommended)

      1. Checkout Server Web Build on how to build the generic web application

      2. Checkout OpenSRP Server Refactor and Clean up for more information
    2. Before Server Refactor and Cleanup
      1. Clone the appropriate OpenSRP Server git repository from https://github.com/OpenSRP/opensrp-server and checkout the correct branch.

        Code Block
        languagebash
        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:
        1. Zambia Electronic Immunization - Branch Name: "path"
        2. TB Reach applicatoin - Branch Name: "tb-reach"
        3. mCare - Branch Name: "mcare-2"
        4. Bangladesh - Branch Name: "bd-family-planning"
        5. Indonesia - Branch Name: "indonesia-server-v2"
      2. (Optional) Import the git repository into your IDE
      3. Update the following files with password credentials (MySQL, PostgreSQL and CouchDB)
        1. assets/config/couchdb.properties
        2. assets/config/opensrp.properties
        3. opensrp-web/src/main/resources/quartz.properties
        4. opensrp-web/src/main/webapp/META-INF/context.xml PostgreSQL credentials
        5. assets/migrations/environments/development.properties PostgreSQL credentials
      4. Build the OpenSRP WAR file in your IDE or maven
        1. If using maven:
          1. Enter the openrsrp-server folder and make sure you're on the correct branch 

            Code Block
            cd opensrp-server
            git status


          2. 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.

      5. 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
        languagebash
        sudo cp opensrp-web/target/opensrp.war /Applications/Tomcat/apache-tomcat-x.x.xx/webapps/


  13. Proceed to install OpenMRS using the OpenMRS Installation Guide