Installer RStudio Serveur sur Ubuntu ServeurInstalling RStudio Server on Ubuntu Server

This tutorial describes the different steps required to install RStudio Server on Ubuntu Server (version 14.04 LTS). It is widely inspired from the official installation instructions

Installing R

First, R must be installed on the server. The best way to do so is to proceed as described on this page, that is:

  • edit the file /etc/apt/sources.list to add your favorite CRAN repository
    deb http://cran.univ-paris1.fr/bin/linux/ubuntu trusty/
    

    (cran.univ-paris1.fr is my favorite CRAN repository because it is managed by my fabulous former lab)

  • add the corresponding GPG keys to your list of keys:
    gpg --keyserver keyserver.ubuntu.com --recv-key E084DAB9
    gpg -a --export E084DAB9 | sudo apt-key add -
    
  • reload the package list and install R
    sudo apt-get update
    sudo apt-get install r-base r-base-dev
    

The best way to install packages is to use the up-to-date packages from RutteR PPA. Install the PPA using:

sudo add-apt-repository ppa:marutter/rrutter
sudo apt-get update

and packages can simply be installed using

sudo apt-get install r-cran-reshape2

for instance (for installing the excellent package reshape2. It is better to install the packages as an admin because they will be available for all users and not only the current user.

Installing RStudio Server

The free version of RStudio Server can be found at this link. The installation is performed by first installing two additional packages (the first one to ease the installation of deb packages and the second one to manage security options in RStudio Server:

sudo apt-get install gdebi-core libapparmor1

Then, the package is downloaded and installed using:

wget http://download2.rstudio.org/rstudio-server-0.98.1091-amd64.deb
sudo gdebi rstudio-server-0.98.1091-amd64.deb

At this step, RStudio Server is maybe accessible at http://my-domain.org:8787. If not (and/or if you want to create a virtual host to access RStudio Server more easily), read the next section.

Last details to check

If you are using a firewall on your server, make sure that the port 8787 is open. In my case, it is managed with shorewall (see this post, in French) and the port can be open by editing the file /etc/shorewall/rules and adding the following line

ACCEPT          net             $FW             tcp     8787

before reloading the firewall configuration

sudo service shorewall restart

 

A virtual host can be set for accessing RStudio Server at an URL of the type http://rstudio.my-domain.org by

  • creating a A field in OVH manager to redirect the URL http://rstudio.my-domain.org to my server’s IP
  • adding the entry http://rstudio.my-domain.org in the file /etc/hosts
  • creating a virtual host with the port redirection. For this step, the following modules must be enabled in apache:
    sudo a2enmod proxy proxy_connect proxy_http
    sudo service apache2 reload
    

    and a file /etc/apache2/site-available/rstudio.conf with

    ServerAdmin me@my-domain.org
    ServerName rstudio.my-domain.org
    
    ProxyPass / http://127.0.0.1:8787/
    ProxyPassReverse / http://127.0.0.1:8787/
    

    must be created. It is activated with:

    sudo a2ensite rstudio
    sudo service apache2 reload
    

    It seems that SSL access to RStudio Server is not available for the free version.
    Users allowed to use RStudio Server are those with a UID larger than 100. Any user created with the command line

    sudo adduser trucmuche
    

    are allowed to connect to a RStudio Server session with their username (trucmuche) and the password given at the account creation.