There are several ways how software can be installed on AWS machines. In this guide, we will not install all software directly on the machine but use Docker as an additional tool to make use of available recipes (Dockerfiles) how to install recent R and RStudioServer on Linux. In this guide, we will assume that the machine has already been launched. The setup requires the following steps:
-
Login to the machine via SSH
-
Install Docker on the machine
-
Run an RStudioServer Docker container
-
Install system libraries in the container that are needed by R packages
-
Install R packages
You can connect to the ubuntu machine on AWS via SSH e.g. from the command line with ssh -i /path/to/your/key.pem [email protected]
, where x.x.x.x is the public IP address of the machine. If you use Windows or MacOS on your computer, other software such as PuTTY can be used.
You can follow the instructions on https://docs.docker.com/engine/install/ubuntu
.
We can use available recipes from the https://github.com/rocker-org project:
sudo docker run -d -p 8787:8787 -e PASSWORD=yourpasswordhere --restart="unless-stopped" rocker/rstudio
Running this command may take while because a lot of software is downloaded. Please notice that after successful creation of the container, this will give you the container ID, which we will need in the next step.
To install software within the container, we must first run:
docker exec -it CONTAINER_ID /bin/bash
This gives us root access in the container and we can install some system libraries hat are needed by r-spatial packages by running:
apt update
apt install libproj-dev libgdal-dev gdal-bin libnetcdf-dev libudunits2-dev
Open your browser and access Rstudio: http://x.x.x.x:8787. If this does not give a a login screen but a URL not found message, you most likely need to add a security rule for making port 8787 accessible in the AWS machine settings.
If the login screen shows up, congratulations, you can login using rstudio
as username and the password given before.
After successflul login, you can install packages as on your local machine, e.g. with:
install.packages("sf","gdalcubes","rstac")