Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
steps for creating and configuring a new AMI with RStudio Server

Building a new RStudio Server AMI

The steps below can be followed to create a new AMI for use with Amazon EC2 instances that includes the latest versions of R, RStudio, and RStudio Server. The idea is inspired by the work of Louis Aslett, who creates and hosts his own public AMIs for RStudio. My own goal was to create an AMI with RStudio v1.0.0 or higher, such that I could use the recent R Notebooks feature. However, the instructions should generally apply for whenever you might be impatient accessing the latest version of R-related software on AWS (via an interactive browser interface...).

Getting started

  1. Create a new EC2 instance with the latest Ubuntu AMI (should be fine to do with Spot); based on Louis Aslett's AMI, I opted to include a general purpose SSD EBS volume with 10GB of storage space
  2. SSH into the instance

Downloading/installing RStudio Server

  1. Follow instructions here:
  2. Run the following command to verify installation:
sudo rstudio-server verify-installation
  1. Add default rstudio user (with password: rstudio) using the following command:
sudo adduser rstudio
  1. Verify rstudio user created with command:
cut -d : -f 1 /etc/passwd

Upgrading R

  1. Following instructions on this page (, run the following commands:
sudo rstudio-server offline
sudo rstudio-server force-suspend-all
  1. Change the CRAN mirror and update R install using the commands below (taken from this post:
codename=$(lsb_release -c -s)
echo "deb $codename/" | sudo tee -a /etc/apt/sources.list > /dev/null
sudo apt-key adv --keyserver --recv-keys E084DAB9
sudo add-apt-repository ppa:marutter/rdev
sudo apt-get update
sudo apt-get upgrade
  1. Run this command to finish the process:
sudo rstudio-server online

Changing web port

  1. Following on instructions on this page (, edit /etc/rstudio/rserver.conf to include this line:
  1. Restart the server:
sudo rstudio-server restart

Installing R packages

  1. Install dependencies for tidyverse package:
sudo apt-get install -y \
    libcurl4-openssl-dev \
    libssl-dev \
    libxml2-dev && \
    sudo apt-get clean && \
    sudo apt-get purge && \
    sudo rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
  1. Open R (via public IP for instance) and install tidyverse package as normal:
  1. Install devtools package as normal:
  1. Install Bioconductors packages:

Creating AMI

  1. In EC2 Console, select current instance
  2. Under ‘Actions’, select ‘Image’ -> ‘Create Image’
  3. Provide name and description for AMI, hit the button to create image
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment