The following, is a step-by-step guide to setup a Shiny Server in AWS along with a method that makes publishing apps easier. The plan is to:

  1. Setup a server, or EC2 instance, in AWS
  2. Install R, Shiny Server and RStudio Server
  3. Pre-install dependencies packages
  4. Publish a test app

Setup the EC2 Instances (Servers) in AWS

The purpose of this section is to provide specific instructions on how to setup one EC2 instance in AWS. Please feel free to skip, or skim, if you are already familiar with the process.

  1. Amazon Machine Instance: Ubuntu
  2. Instance Type: m4.large
  3. Storage: 30 Size GiB
  4. Security Group Name: Shiny
  5. Click Add Rule, select Type: All Trafic, Source: My IP
  6. Optional: If you want to open your Shiny server to the world: Click Add Rule, select Type: Custom TCP Rule, Port Range: 3838, Source: Anywhere
  7. Optional: If you plan to have to publish apps from a RStudio server within your “local” AWS network (VPC): Click Add Rule, select Type: All Traffic, Source: Custom and type the the first two numbers in the IP address followed by ‘.0.0/16’ (e.g.: If the Shiny server’s AWS internal IP address is then you’d enter This gives every server in your VPC access to your Shiny server and to each other). See Publish to a Shiny Server after completing this guide
  8. After clicking Launch, the “Select existing pair or create a new pair” screen will appear, select: Create a new pairKey pair name, and name it shiny
  9. Click Download Key Pair
  10. Save the file
  11. Click Launch Instances
  12. Go to the Instances section in the EC2 Dashboard section and click on the new instance
  13. Copy the Public DNS address, from here on we’ll refer to it as MY_PUBLIC_DNS

Connecting to the Server

The Ubuntu Server installation does not have a GUI that the Destktop version provides. This means that the only way to make changes to the server is by starting a Terminal (black screen) session with the EC2 server. AWS provides the step-by-step instructions for this part:

Windows Complete sections Converting Your Private Key Using PuTTYgen and Starting a PuTTY Session

Non-Windows Only go through the instructions in the To connect to your instance using SSH section Shiny server configuration

Install R

Tip: The terminal commands inside the boxes can be copied and pasted into your terminal session. In putty you can use right-click as the “paste” command.

  • Ubuntu defaults to an older version of R. Update the Linux package list so that Ubuntu installs the latest R version. For more info see:

    sudo sh -c 'echo "deb xenial/" >> /etc/apt/sources.list'
    gpg --keyserver --recv-key E084DAB9
    gpg -a --export E084DAB9 | sudo apt-key add -
    sudo apt-get update
  • Install R

    sudo apt-get install r-base

Install Shiny

The instructions below install the current version of Shiny Server. To find updated instructions navigate to: and select Ubuntu 12.04 or later

sudo su - -c "R -e \"install.packages('shiny', repos='')\""
sudo apt-get install gdebi-core
sudo gdebi shiny-server-

Install RStudio

Why install RStudio Server along Shiny Server? The RStudio Server provides a web browser-based interface that looks just like the local RStudio Desktop. In this case, the RStudio Server will be used to upload the app and its dependencies. It will also allow testing of the app inside the RStudio IDE. This removes the need to setup complicated security and FTP. To find updated instructions navigate to: and select Debian/Ubuntu

sudo gdebi rstudio-server-1.1.383-amd64.deb

Setup an admin user

A new Linux user needs to be setup that can logon to RStudio Server and also has sufficient rights to save to the Shiny Server’s apps folder.

  • Create a default user that can log on RStudio. I’m going to use ‘rstudio’ as the name but it can be whatever you’d like.

    sudo adduser rstudio
    ## Select and type a password 
  • Give the new user ‘sudo’ (read Admin) access to the server.

    sudo usermod -aG sudo rstudio
  • This command is key, it makes it where you don’t have to type ‘sudo’ before any file/folder command. This command makes it possible for RStudio to create new folders and files in the Shiny Server apps folder

    sudo chown rstudio /srv/shiny-server/

Pre-install packages

Some popular R packages depend on Linux packages that are usually not installed by default. Install the following Linux packages:

sudo apt-get -y install libcurl4-gnutls-dev
sudo apt-get -y install libssl-dev
sudo apt-get -y install libxml2-dev

Any package that a ‘Shiny App’ uses will need to be pre-installed, or the app will crash. Here are a few we will load before we start using the server. If you need any other package, just follow the instruction pattern, replacing the name of the desired package. You can always install more packages later via a terminal session

sudo su - -c "R -e \"install.packages('tidyverse', repos='')\""
sudo su - -c "R -e \"install.packages('stats', repos='')\""
sudo su - -c "R -e \"install.packages('flexdashboard', repos='')\""
sudo su - -c "R -e \"install.packages('shinydashboard', repos='')\""

Test server connnectivity

To confirm the Shiny server is working go to: http://MY_PUBLIC_DNS:3838/ To confirm the RStudio server is working go to: http://MY_PUBLIC_DNS:8787/

Publishing apps

Publishing from within the RStudio Server

  1. Navigate to the RStudio server: http://MY_PUBLIC_DNS:8787/
  2. Log on as ‘rstudio
  3. Confirm that the latest version of R is loaded (As of today is 3.4.2)
  4. Click File – New File – Shiny Web App
  5. Application Name: my_test
  6. Click Browse
  7. Click on the Go to directory button, identified as […]
  8. Type the following (exactly as is in here): /srv/shiny-server/
  9. Click Choose and then click Create
  10. Navigate to your new app by going to: http://MY_PUBLIC_DNS:3838/my_test