This procedure was tested on Ubuntu 23.04 but should be very similar or identical on other verions.
Note that this will likely not install the latest version of R but the one that is included in the Ubuntu package repository. Installing a newer version can be tricky since the R project doesn't always support all recent releases of major Linux distributions. For most use cases, especially for education, the slightly older version of R will be prefectly fine though.
All commands in this guide need to be run as user root or with sudo.
apt update
apt upgrade
This user should be used for admin work, not in RStudio
useradd -m admin
usermod -a -G sudo admin
passwd admin # set strong password!
Make sure at least one sudo capable account exists before this step! Otherwise you might lock yourself out.
in /etc/ssh/sshd_config set the following values:
PermitRootLogin no
PubkeyAuthentication yes
PasswordAuthentication no
ufw default deny incoming
ufw default allow outgoing
ufw allow ssh
ufw allow http
ufw allow https
ufw show added # double check the changes before applying
ufw enable
apt install r-base r-base-dev
apt install libxml2-dev libfontconfig1-dev libharfbuzz-dev libfribidi-dev libfreetype6-dev libpng-dev libtiff5-dev libjpeg-dev libcurl4-openssl-dev libssl-dev
R
install.packages("tidyverse")
Check https://posit.co/download/rstudio-server/ for current builds of rstudio-server.
There may be unavailable dependencies, but the nightly builds might fix that: https://dailies.rstudio.com
apt install gdebi-core
wget https://s3.amazonaws.com/rstudio-ide-build/server/jammy/amd64/rstudio-server-2023.12.0-daily-161-amd64.deb
gdebi rstudio-server-2023.12.0-daily-161-amd64.deb
Check server status:
systemctl status rstudio-server
(replace rstudio.example.org with your domain)
apt install nginx
apt install certbot python3-certbot-nginx
certbot certonly --nginx -d rstudio.example.org
Write /etc/nginx/sites-available/rstudio:
server {
listen 80;
server_name rstudio.example.org;
return 301 https://rstudio.example.org$request_uri;
}
server {
listen 443 ssl;
server_name rstudio.example.org;
ssl_certificate /etc/letsencrypt/live/rstudio.example.org/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/rstudio.example.org/privkey.pem;
ssl_prefer_server_ciphers on;
location / {
proxy_pass http://localhost:8787;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
Test NGINX config:
nginx -t
Restart NGINX:
systemctl restart NGINX
Open https://rstudio.example.org in your browser and login with a regular linux user account.
RStudio server is now ready to use. User's files (e.g. R PRojects, etc) are kept in their home directories.
useradd -m [name]
passwd [name]
Haha, thanks. It's not really a tutorial but more like my personal notes so I don't forget things next time :D
I don't think RStudio server has any user management stuff built-in since it just uses the OS' user accounts. Another issue is how to create those accounts in the first place, for example in a university setting where students probably have an email account from the institution but that doesn't translate into a system account on the RStudio server