Skip to content

Setting up a REDCap instance on Azure

Aditya Chinchure edited this page Aug 29, 2020 · 2 revisions

Important information:

This guide is written and tested for the following versions of REDCap and LAMP, and is intended for the purpose of testing LEAP's capabilities with REDCap.

REDCap Version: 9.5.33

LAMP by Bitnami: LAMP 7.4.9-2-r02 (Debian 10)

Step 1: Download REDCap

Download REDCap: https://community.projectredcap.org/page/download.html

Version: 9.5.33

Step 2: Setup a LAMP instance on Azure

REDCap is a PHP application that is built on the LAMP stack and depends on MySQL and an Apache web server. The easiest way to setup the LAMP stack on Azure is to use an existing template that automatically sets up all components for us. I chose LAMP by Bitnami because it is the most popular and recommended LAMP templates for Azure.

Step 2.1: Create a resource


Step 2.2: Search for "LAMP by Bitnami" and hit create


Step 2.3: Configure settings

The only things that need configuration are the project details and the auto-shutdown settings, the rest are set to default. I am configuring it to use an SSH key which will be generated when I create the instance.


Step 2.4: Create the instance, download the SSH Key and store the key safely

At this point, Azure will deploy all the resources in the new resource group.


Step 3: Setting up the VM

Step 3.1: Make the IP address static

Go to your resource group, then to your VM:


Click on the IP address:


Change the IP configuration to be Static, so that we can use it in LEAP. Hit the save button, and it will reboot the VM automatically.


Step 3.2: Configure the NSG

The goal here is to implement extra safety so that only my computer can access the REDCap instance. I do so by configuring the Network Security Group to restrict source IP addresses to only my computer's address.

Go back to your resource group, and click on the NSG instance.


Click on HTTP, change source to IP Addresses, and enter your source IP. I am restricting access to only my LEAP instance running locally on my computer, therefore I am adding my own IP address (https://www.whatismyip.com to get your public IP)


Repeat this step for HTTPS and SSH to restrict access in a similar manner.

At this point, visit the IP address of the VM and ensure that it loads correctly.


Step 3.3: Obtain the PHP My Admin password

https://docs.bitnami.com/azure/infrastructure/lamp/get-started/access-phpmyadmin/

Go to your VM instance -> Boot Diagnostics (left sidebar under Support + troubleshooting)


View the Serial log, and scroll down until you find the PHP password:


Step 3.4: Access phpMyAdmin

Finally, we can use an SSH tunnel to use phpMyAdmin

In the terminal:

chmod 400 REDCap-1_key.pem
ssh -N -L 8888:127.0.0.1:80 -i REDCap-1_key.pem adityachinchure@<IP-address>

You can now access phpMyAdmin on http://localhost:8888/phpmyadmin/

Login as root, with the password you got from the serial log


Step 4: Setup REDCap

Step 4.1: Create a redcap database

CREATE DATABASE IF NOT EXISTS `redcap`;

Create a database.


Step 4.2: Copy redcap files to the server:

  • unzip the downloaded redcap files
  • in database.php, update the db username to root and password to the root user password from the boot diagnostics log, and also add a string to the salt variable. Note that using the root user here is not safe for production environments, but for the sake of simplicity this will do.
  • clone the leap_connector module into the modules folder. Rename the LEAP Connector folder to leap_connector_v0.

Step 4.3: Now, we can copy those files to the Azure VM

I am storing the files in the htdocs folder, with the path /redcap. This is so that I can access the redcap instance at the URL: <ip-address>/redcap

scp -i REDCap-1_key.pem -r <PATH TO `redcap` FOLDER> adityachinchure@<IP-address>:/opt/bitnami/apache2/htdocs/redcap

Step 4.4: SSH into the instance and chmod the redcap folder

REDCap needs write access to change files on the server, such as for downloading and using external modules or importing data

ssh -i REDCap-1_key.pem adityachinchure@<IP-address>

Once logged in, run this:

cd /opt/bitnami/apache2/htdocs/ && chmod -R 777 redcap

Step 4.5: Finish REDCap install

Follow the instructions by visiting http://<IP-address>/redcap/install.php


Step 5: Enable Table-based auth on REDCap

Note: this may not work on older versions of REDCap because an email server is not set up.

Step 5.1: Create a new user

Go to Control Center -> Add Users


IMPORTANT: Save the link to reset the password in a safe place. Do not visit it yet.


Step 5.2: Set yourself as an administrator:

Go to Control Center -> Administrators & Acct Managers and add yourself as an admin.


Step 5.2: Enable table based auth

Go to Control Center -> Security & Authentication, choose Table based authentication and hit save.

Now if you refresh the page, you will be taken to a login page.

Step 5.3: Reset your password using the saved link from step 5.1

Step 5.4: Remove site_admin as an admin

Go to Control Center -> Administrators & Acct Managers and remove site_admin


You can now enable the LEAP external module and use it! For more info on that, visit the guide here: https://github.com/leap-project/leap/wiki/Setup-a-REDCap-Connection

Clone this wiki locally