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).
www.bohemia.team
.pem
file into your /home/<username>/.ssh/id_rsa
directorychmod 400 ~/.ssh/openhdskey.pem
18.218.87.64
ssh-keygen -t rsa -b 4096 -C “youremail@host.com”
/home/<username>/.ssh/id_rsa
ls ~/.ssh/id_*
(this will show your key)chmod 400 ~/.ssh/id_rsa
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'
source ~/.bashrc
shiny
to ssh into the serversudo 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
sudo adduser <username_of_new_user>
sudo adduser <username_of_new_user> --disabled-password
. For example:
sudo adduser benmbrew --disabled-password
sudo su - benmbrew
.ssh
directory for the new user and change permissions:
mkdir .ssh; chmod 700 .ssh
.ssh
dir and change permissions: touch .ssh/authorized_keys; chmod 600 .ssh/authorized_keys
sudo usermod -a -G sudo benmbrew
ssh -i "/home/joebrew/.ssh/openhdskey.pem" ubuntu@bohemia.team
or
shiny # if you set up the alias as per previous instructions
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
(No need, since it's all already installed via the AMI)
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')\""
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
# 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
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.