Installing RStudio Server on Ubuntu Server

[This article was first published on tuxette-chix » R, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

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 E298A3A825C0D65DFD57CBB651716619E084DAB9
    gpg -a --export E298A3A825C0D65DFD57CBB651716619E084DAB9 | 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 [email protected]
    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.

To leave a comment for the author, please follow the link and comment on their blog: tuxette-chix » R.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)