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...).
- 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
- SSH into the instance
- Follow instructions here: https://www.rstudio.com/products/rstudio/download-server/
- Run the following command to verify installation:
sudo rstudio-server verify-installation
- Add default rstudio user (with password: rstudio) using the following command:
sudo adduser rstudio
- Verify rstudio user created with command:
cut -d : -f 1 /etc/passwd
- Following instructions on this page (https://support.rstudio.com/hc/en-us/articles/200716773-Upgrading-the-Version-of-R-on-RStudio-Server), run the following commands:
sudo rstudio-server offline
sudo rstudio-server force-suspend-all
- Change the CRAN mirror and update R install using the commands below (taken from this post: https://askubuntu.com/questions/614530/how-to-install-latest-version-of-r-on-ubuntu-12-04-lts)
codename=$(lsb_release -c -s)
echo "deb http://cran.fhcrc.org/bin/linux/ubuntu $codename/" | sudo tee -a /etc/apt/sources.list > /dev/null
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E084DAB9
sudo add-apt-repository ppa:marutter/rdev
sudo apt-get update
sudo apt-get upgrade
- Run this command to finish the process:
sudo rstudio-server online
- Following on instructions on this page (https://support.rstudio.com/hc/en-us/articles/200552316-Configuring-the-Server), edit /etc/rstudio/rserver.conf to include this line:
www-port=80
- Restart the server:
sudo rstudio-server restart
- 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/*
- Open R (via public IP for instance) and install
tidyverse
package as normal:
install.packages(“tidyverse”)
- Install
devtools
package as normal:
install.packages(“devtools”)
- Install Bioconductors packages:
source("https://bioconductor.org/biocLite.R”)
biocLite()
- In EC2 Console, select current instance
- Under ‘Actions’, select ‘Image’ -> ‘Create Image’
- Provide name and description for AMI, hit the button to create image