Skip to content

komalsrathi/shiny-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 

Repository files navigation

Shiny Server

Authors: Komal Rathi
Contact: rathik@email.chop.edu
Organization: DBHi, CHOP
Status: This is "work in progress"
Date: 2024-09-18

Set up Shiny Server:

Upload all data to server

scp -r your-app-name server:/path/to/shiny-apps/

Install R

sudo yum update
sudo yum install R
sudo yum install libcurl-devel openssl-devel

Change Rprofile

sudo vi /usr/lib64/R/library/base/R/Rprofile

# add the following to the Rprofile
# download method
options(download.file.method = "libcurl")

# default CRAN mirror
local({
  r <- getOption("repos")
  r["CRAN"] <- "https://cran.rstudio.com/"
  options(repos=r)
})

Install Shiny

sudo su - -c "R -e \"install.packages('shiny')\""

Install Shiny Server

wget https://download3.rstudio.org/centos5.9/x86_64/shiny-server-1.4.4.801-rh5-x86_64.rpm
sudo yum install --nogpgcheck shiny-server-1.4.4.801-rh5-x86_64.rpm

# To manually start or stop the server, you can use the following commands.
sudo systemctl start shiny-server
sudo systemctl stop shiny-server
sudo systemctl restart shiny-server
sudo systemctl status shiny-server

# Should shiny server should be run automatically at boot time
sudo systemctl enable shiny-server
sudo systemctl disable shiny-server

# fetch all your data in corresponding app directory
# do this before installing R packages
sudo mount -o remount,exec /tmp
export TMPDIR=~/tmp # or do this. I had to do this after the latest upgrade.

# now install packages
sudo R

Edit config file to add your app

sudo vi /etc/shiny-server/shiny-server.conf

# Instruct Shiny Server to run applications as the user "shiny"
run_as shiny;
preserve_logs true; # this is required to preserve logs

# Define a server that listens on port 3838
server {
  listen 3838;

  # Define a location at the base URL
  location / {

    # Host the directory of Shiny Apps stored in this directory
    site_dir /srv/shiny-server;

    # Log all Shiny output to files in this directory
    log_dir /var/log/shiny-server;

    # When a user visits the base URL rather than a particular application,
    # an index of the applications available in this directory will be shown.
    directory_index on;
  }

  # Define location of your app
  location /your-app-name {

    # application directory
    app_dir //;

    # log directory
    log_dir /path/to/shiny-apps/your-app-name/logs;

    # directory structure
    directory_index on;
  }
}

Turn off firewall

sudo firewall-cmd --zone=public --add-port=3838/tcp --permanent && sudo firewall-cmd --zone=public --add-port=3838/tcp

About

Documentation on creating a shiny server

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published