Install R and RStudio Server on Debian 9
When working on data science problems you'll probably come in touch with the well known statistical software package R. While R, due to its long history, is an extremely versatile & powerful system for almost any analytical task, it's not known for its user-friendliness and can sometimes be challenging to setup locally.
RStudio is a very usable frontend which can be installed and used on different platforms (Linux, Windows, MacOS) locally.
This works mostly well but offers some potential downsides like the problematic installation and/or removal of R/Rstudio or the fact that the local machine is not powerful enough to handle the necessary workload.
One solution here could be to install R and Rstudio Server as an web browser frontend on an dedicated and, if necessary, more powerful server.
Let's see how to quickly do it on Debian 9!
Prerequisite
Install Debian Packages for R
deb http://cloud.r-project.org/bin/linux/debian stretch-cran35/
to the file /etc/apt/sources.list.
sudo apt-key adv --keyserver keys.gnupg.net --recv-key 'E19F5F87128899B192B1A2C2AD5F960A256A04AF'
sudo apt-get install dirmngr
sudo apt-get update
sudo apt-get install r-base r-base-dev
Install RStudio Server
sudo apt-get install gdebi-core
wget https://download2.rstudio.org/server/debian9/x86_64/rstudio-server-1.3.1093-amd64.deb
sudo gdebi rstudio-server-1.3.1093-amd64.deb
Create a user
Now you should create one or more local user on the server which credentials will be used for the login in the RStudio web frontend:
root@rsrv:~# adduser ruser
Adding user `ruser' ...
Adding new group `ruser' (1001) ...
Adding new user `ruser' (1001) with group `ruser' ...
Creating home directory `/home/ruser' ...
Copying files from `/etc/skel' ...
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Changing the user information for ruser
Enter the new value, or press ENTER for the default
Full Name []:
Room Number []:
Work Phone []:
Home Phone []:
Other []:
Is the information correct? [Y/n] y
Now you should be able to open the web frontend of RStudio in any browser on any system that has access to your server running RStudio (here the IP is 192.168.2.121):
Consider that the web frontend is running on the non-standard (http) port 8787.
RStudio web frontend – Login screen
The free RStudio Server is only running unencrypted over http and thus should only be used in an internal network. An workaround for this would be to run an reverse proxy which provides a secure SSL connection.
For this Apache or NGINX are good options.
RStudio web frontend – Up & running!
Conclusion
In this article we've installed R and RStudio Server on a Debian 9 server.