Installing RStudio Server on AWS

2 minute read


Having Rstudio running in-browser, where ever you go, with completely scalable performance is an attractive option.

This guide is intended to be the minimum config steps required to acheive this and assumes you are happy to do your own research into pricing, security and setup preferences.


  • Set up an account at

  • Sign into the AWS console

  • Navigate to Services > EC2

  • Select Launch Instance

Configure Instance

a) Select appropriate AMI: I recommend a general purpose Linux setup running Ubuntu.

b) Select instance type: Here I have selected a t2.micro instance as a low cost option. Scale as required, beware of costs.

c) Configure Security Group: In order to allow traffic from anywhere to get to the rstudio server we need to open port 8787 and also 3838 if we want to use shiny server on this instance also. This requires adding some custom security rules. You may want to restrict access from a recognised IP range.

Server Setup

a) Locate Private Key: You will be prompted to download a key file *.pem. Start by opening a terminal window. cd to the directory where you saved the *.pem file. I have called mine rstats.pem. To ensure this secret key file cannot be located, change permissions as follows (replacing with your file name):

$ chmod 400 rstats.pem

b) Connect to server via SSH: Here you want to replace details with your specific key file and instance name. Refer to the ‘Connect’ tab within your EC2 dashboard for pre-populated commands to run. You should notice in your terminal window that you are now connected to your Amazon EC2 Instance.

$ ssh -i "rstats.pem" ubuntu@<<Public DNS (IPv4)>>

Install R

Run the below at the terminal window. Replace the CRAN mirror and linux details below based on your server version and R version. see here for more info.

$ sudo su -c "echo 'deb xenial-cran35/' >> /etc/apt/sources.list"
$ sudo apt-key adv --keyserver --recv-keys E084DAB9
$ sudo apt-get update
$ sudo apt-get upgrade -y
$ sudo apt-get dist-upgrade -y
$ sudo apt-get install r-base

Install RStudio Server

Refer to the Rstudio website for the latest version and replace below.

$ sudo apt-get install gdebi-core
$ wget
$ sudo gdebi rstudio-server-1.1.453-amd64.deb

Now you can navigate to:

http://<Public DNS (IPv4)>:8787

to verify the RStudio Server install was successful.

Add users

In order to login: add a user, password and make a home directory.

$ sudo useradd rstudio
$ sudo mkdir /home/rstudio
$ sudo passwd rstudio
$ sudo chmod -R 0777 /home/rstudio