Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added docs/assets/R/rstudio-server-login.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/R/rstudio-server-page.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
---
author:
name: Sam Foo
email: docs@linode.com
description: 'RStudio Server is a the web based version of RStudio for a desktop environment. Gain access to your R development environment from anywhere in the world.'
og_description: 'RStudio Server is a the web based version of RStudio for a desktop environment. Gain access to your R development environment from anywhere in the world.'
keywords: ['R', 'statistic', 'R Foundation', 'data visualization']
license: '[CC BY-ND 4.0](https://creativecommons.org/licenses/by-nd/4.0)'
modified: 2018-01-23
modified_by:
name: Linode
published: 2018-01-23
title: 'How to Deploy RStudio Server Using an NGINX Reverse Proxy'
---

## Before You Begin

This guide assumes an R installation version of R 3.0.1+ and will be installing RStudio Server 1.1. See our guide on [installing R on Ubuntu and Debian](/docs/development/how-to-install-r-on-ubuntu-and-debian) for steps on installing the latest version of R.

The steps in this guide are for Ubuntu 16.04 and should be adapted to your specfic distribution installation.

## Install RStudio Server

1. Download RStudio 1.1:

wget https://download2.rstudio.org/rstudio-server-1.1.414-amd64.deb

2. Install and use the gDebi package installer for the downloaded Debian package file.

sudo apt install gdebi
sudo gdebi rstudio-server-1.1.414-amd64.deb

If successful, the output should show `rstudio-server.service` as active.

{{< output >}}
Created symlink from /etc/systemd/system/multi-user.target.wants/rstudio-server.service to /etc/systemd/system/rstudio-server.service.
● rstudio-server.service - RStudio Server
Loaded: loaded (/etc/systemd/system/rstudio-server.service; enabled; vendor preset: enabled)
Active: active (running) since Tue 2018-01-23 21:18:44 UTC; 1s ago
Process: 13676 ExecStart=/usr/lib/rstudio-server/bin/rserver (code=exited, status=0/SUCCESS)
Main PID: 13677 (rserver)
CGroup: /system.slice/rstudio-server.service
└─13677 /usr/lib/rstudio-server/bin/rserver

Jan 23 21:18:44 localhost systemd[1]: Starting RStudio Server...
Jan 23 21:18:44 localhost systemd[1]: Started RStudio Server.
{{< /output >}}

3. On a browser, navigate to your Linode's public ip address on port 8787, `public-ip:8787`. The users and passwords are the same from the login credits of the Linux users.

![RStudio Server Login](/docs/assets/R/rstudio-server-login.png)

4. Instead of binding the RStudio server to the public IP, set RStudio Server to listen on localhost in the `rserver.conf` file.

{{< file-excerpt "/etc/rstudio/rserver.conf" >}}
# Server Configuration File
www-address=127.0.0.1
{{< /file-excerpt >}}

5. Configuration for each individual session can also be set. For example, the default session timeout is two hours. Change this to 30 minutes to conserve server resources.

{{< file-excerpt "/etc/rstudio/rsession.conf" >}}
# R Session Configuration File
session-timeout-minutes=30
{{< /file-excerpt >}}

6. Changes to the configuration files can be checked:

sudo rstudio-server verify-installation

If there are no issues, restart RStudio server to apply the changes.

sudo rstudio-server restart

## Set up the Reverse Proxy

Running Rstudio server under a reverse proxy offers benefits such as being able to pick the URL endpoints and load balancing.

1. Under the http block of `nginx.conf`, add the following configuration:

{{< file-excerpt "/etc/nginx/nginx.conf" nginx >}}
http {
# Basic Settings
# ...

map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
}
{{< /file-excerpt >}}

2. Create an NGINX configuration in `/etc/nginx/conf.d/` called `rstudio.conf` with the following configuration. Replace `example.com` with the public IP address or FDQN of your Linode.

{{< file-excerpt "/etc/nginx/conf.d/rstudio.conf" nginx >}}
server {
listen 80;
listen [::]:80;

server_name example.com;

location / {
proxy_pass http://localhost:8787/;
proxy_redirect http://localhost:8787/ $scheme://$host/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_read_timeout 20d;
}
}
{{< /file-excerpt >}}

3. Check the NGINX configuration by:

sudo nginx -t

4. If there are no errors, restart NGINX to apply the changes.

sudo systemctl restart nginx

5. On a browser, navigate to the public IP or FDQN of your Linode. After logging in, the RStudio IDE should be available from your browser.

![Rstudio Screen](/docs/assets/R/rstudio-server-page.png)
150 changes: 150 additions & 0 deletions docs/development/how-to-install-r-on-ubuntu-and-debian.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
---
author:
name: Sam Foo
email: docs@linode.com
description: 'R is a programming language used heavily for statistical analysis and data visualization. Learn how to install this on your Linode.'
og_description: 'R is a programming language used heavily for statistical analysis and data visualization. Learn how to install this on your Linode.'
keywords: ['R', 'statistic', 'R Foundation', 'data visualization']
license: '[CC BY-ND 4.0](https://creativecommons.org/licenses/by-nd/4.0)'
modified: 2018-01-23
modified_by:
name: Linode
published: 2018-01-23
title: 'How to install R on Ubuntu and Debian'
---

[R is a programming language](https://www.r-project.org/about.html) used for statistical analysis in addition to data visualization. The language is highly extensible with the [Comprehensive R Archive Network(CRAN)](https://cran.r-project.org/) that hosts various R packages to produce publication quality figures, specialized computational tools, and more.

Although R can be installed through the default Debian or Ubuntu repository, the method outlined in this guide will ensure having the most up-to-date stable release.

## Install R on Ubuntu 16.04 and Debian 9

1. Open `/etc/apt/sources.list` and add the following line to the end of the file:

Ubuntu:

deb http://cran.rstudio.com/bin/linux/ubuntu xenial/

Debian:

deb http://cran.rstudio.com/bin/linux/debian stretch-cran34/

2. Add the key ID for the CRAN network:

[UBuntu GPG key](https://cran.rstudio.com/bin/linux/ubuntu/):

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E084DAB9

[Debian GPG key](https://cran.rstudio.com/bin/linux/debian/):

sudo apt install dirmngr
sudo apt-key adv --keyserver keys.gnupg.net --recv-key 'E19F5F87128899B192B1A2C2AD5F960A256A04AF'

3. Update the repository.

sudo apt update

4. Install the R binaries.

sudo apt install r-base

## Download Packages from CRAN

1. Open the R interpreter:

R

2. The interpreter will open with some information about the version. Enter `install.packages("ggplot2")`

{{< output >}}
R version 3.4.3 (2017-11-30) -- "Kite-Eating Tree"
Copyright (C) 2017 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> install.packages("ggplot2")
{{< /output >}}

3. A list of available mirrors should appear. Pick the closest location to maximize transfer speeds.

{{< output >}}
--- Please select a CRAN mirror for use in this session ---
HTTPS CRAN mirror

1: 0-Cloud [https] 2: Algeria [https]
3: Australia (Canberra) [https] 4: Australia (Melbourne 1) [https]
5: Australia (Melbourne 2) [https] 6: Australia (Perth) [https]
7: Austria [https] 8: Belgium (Ghent) [https]
9: Brazil (PR) [https] 10: Brazil (RJ) [https]
11: Brazil (SP 1) [https] 12: Brazil (SP 2) [https]
13: Bulgaria [https] 14: Canada (MB) [https]
15: Chile 1 [https] 16: Chile 2 [https]
17: China (Beijing) [https] 18: China (Hefei) [https]
19: China (Guangzhou) [https] 20: China (Lanzhou) [https]
21: China (Shanghai) [https] 22: Colombia (Cali) [https]
23: Czech Republic [https] 24: Denmark [https]
25: East Asia [https] 26: Ecuador (Cuenca) [https]
27: Estonia [https] 28: France (Lyon 1) [https]
29: France (Lyon 2) [https] 30: France (Marseille) [https]
31: France (Montpellier) [https] 32: France (Paris 2) [https]
33: Germany (Göttingen) [https] 34: Germany (Münster) [https]
35: Greece [https] 36: Iceland [https]
37: India [https] 38: Indonesia (Jakarta) [https]
39: Ireland [https] 40: Italy (Padua) [https]
41: Japan (Tokyo) [https] 42: Japan (Yonezawa) [https]
43: Malaysia [https] 44: Mexico (Mexico City) [https]
45: New Zealand [https] 46: Norway [https]
47: Philippines [https] 48: Serbia [https]
49: Singapore (Singapore 1) [https] 50: Spain (A Coruña) [https]
51: Spain (Madrid) [https] 52: Sweden [https]
53: Switzerland [https] 54: Taiwan (Chungli) [https]
55: Turkey (Denizli) [https] 56: Turkey (Mersin) [https]
57: UK (Bristol) [https] 58: UK (Cambridge) [https]
59: UK (London 1) [https] 60: USA (CA 1) [https]
61: USA (IA) [https] 62: USA (IN) [https]
63: USA (KS) [https] 64: USA (MI 1) [https]
65: USA (NY) [https] 66: USA (OR) [https]
67: USA (TN) [https] 68: USA (TX 1) [https]
69: Vietnam [https] 70: (HTTP mirrors)


Selection:
{{< /output >}}

4. When quitting the interpreter, there will be a prompt to save the workspace image. If yes, this will save all the user defined objects for the next session.

> q()
Save workspace image? [y/n/c]:

## RStudio IDE Desktop

The R interpreter lacks features such as a debugger which may be needed for larger projects. RStudio is an IDE that comes with many tools for development right out of the box.

1. Download RStudio as a Debian package.

wget https://download1.rstudio.org/rstudio-xenial-1.1.414-amd64.deb

2. Install via:

sudo dpkg -i rstudio-xenial-1.1.414-amd64.deb

{{< note >}}
If there are missing dependencies, those can be installed with the following command:

sudo apt install -f
{{< /note >}}