misc/guide.md

Admin guide for setting up the HEFPI shiny application

The below guide is a walk-through of setting up the HEFPI shiny web application. For the sake of example and reproducibility, this guide assumes you are deploying to AWS EC2 - if you using a different cloud service, or if deploying on a local physical server, the process will be slightly different (but much will be the same).

Buy a domain

Get an EC2 instance

Configuring a key pair

Allocate a persistent IP

18.218.87.64

Associate the domain and IP address

Setting up SSH keys

Connect to the servers

ssh -i "/home/joebrew/.ssh/openhdskey.pem" ubuntu@ec2-18-218-87-64.us-east-2.compute.amazonaws.com
or
ssh -i "/home/joebrew/.ssh/openhdskey.pem" ubuntu@bohemia.team
alias shiny='ssh -i "/home/joebrew/.ssh/openhdskey.pem" ubuntu@bohemia.team'

Setting up https

sudo apt-get update
sudo apt-get install software-properties-common
sudo add-apt-repository universe
sudo add-apt-repository ppa:certbot/certbot
sudo apt-get update
sudo apt-get install certbot python-certbot-nginx
sudo certbot run --nginx --non-interactive --agree-tos -m joebrew@gmail.com --redirect -d bohemia.team

Managing users (ie, creating ssh keypairs for other users)

Setting up Linux

ssh -i "/home/joebrew/.ssh/openhdskey.pem" ubuntu@bohemia.team

or

shiny # if you set up the alias as per previous instructions

Installing some Libraries

We'll install some libraries (most are installed via the AMI, but we'll have this here to catch those that weren't):

sudo apt-get -y install \
    nginx \
    gdebi-core \
    apache2-utils \
    pandoc \
    pandoc-citeproc \
    libssl-dev \
    libcurl4-gnutls-dev \
    libcairo2-dev \
    libgdal-dev \
    libgeos-dev \
    libproj-dev \
    libxml2-dev \
    libxt-dev \
    libv8-dev \
    libmagick++-dev
sudo apt-get update
sudo apt-get install default-jre
sudo apt-get install default-jdk
sudo R CMD javareconf

Install R, shiny, and RStudio server

(No need, since it's all already installed via the AMI)

Set up RStudio for the browser

Get the app packages set up

cd /home/rstudio/ShinyApps/shiny
R
sudo su - -c "R -e \"install.packages('readxl')\""
sudo su - -c "R -e \"devtools::install_github('rstudio/DT')\""
sudo su - -c "R -e \"devtools::install_github('aoles/shinyURL')\""
sudo su - -c "R -e \"install.packages('shinydashboard')\""
sudo su - -c "R -e \"install.packages('shiny')\""
sudo su - -c "R -e \"install.packages('RPostgreSQL')\""
sudo su - -c "R -e \"install.packages('devtools')\""
sudo su - -c "R -e \"install.packages('tidyverse')\""
sudo su - -c "R -e \"install.packages('xlsx')\""

Set up shiny server

sudo cp -r /home/rstudio/ShinyApps/shiny /srv/shiny-server/
sudo /opt/shiny-server/bin/deploy-example default
sudo cp -r /home/rstudio/ShinyApps/shiny /srv/shiny-server/sample-apps/
sudo cp -r /home/rstudio/ShinyApps/shiny /srv/shiny-server/
sudo systemctl restart shiny-server
sudo ufw allow 3838/tcp
sudo ufw allow 80/tcp
cd /srv/shiny-server
chmod 555 shiny
sudo systemctl restart shiny-server

Quick deploy

# Local machine
# run dev then git update

# Remote machine
sudo rm -r /srv/shiny-server/hefpi
sudo mkdir /srv/shiny-server/hefpi
sudo su - -c "R -e \"remove.packages('hefpi')\""
sudo su - -c "R -e \"devtools::install_github('databrew/hefpi', dependencies = TRUE, force = TRUE)\""
sudo chmod a+rwx /srv/shiny-server/hefpi
touch /srv/shiny-server/hefpi/app.R
echo "library(hefpi); hefpi::run_app()" >> /srv/shiny-server/hefpi/app.R
sudo systemctl restart shiny-server


databrew/hefpi documentation built on March 30, 2023, 3:58 p.m.