I recently needed to do some bioinformatics analysis in R, and my Mac’s compute power just wasn’t up to it. As it happens, I have a server where I live, so naturally I wondered whether I could run it there instead. Using ssh from the Mac to connect to the Linux server and run the code from a terminal would normally be convenient enough, but there were a couple of problems:

  1. The user isn’t very comfortable with Linux and only knows how to use the graphical RStudio.
  2. Even with ssh, the server where I live doesn’t have a public IP, so that option was off the table too.

1. Introducing RStudio Server

RStudio is a visual IDE for R, letting you write and run R code. It now comes in two versions: local and server.

  • The local version runs entirely on your own machine, relying on your local machine’s performance, with no server needed.
  • The server version can take full advantage of a server’s compute power, and other computers can access it through a browser — the experience is the same as using RStudio locally.

2. Installation

Just follow the official tutorial:

1 Choose your operating system

Choose RHEL9 under RedHat/CentOS.

2 Install R

sudo dnf install R
sudo dnf install R-devel

Once installed, you can run R from the command line:

R

R_installed

3 Install RStudio Server

wget https://download2.rstudio.org/server/rhel9/x86_64/rstudio-server-rhel-2023.06.0-421-x86_64.rpm
sudo yum install rstudio-server-rhel-2023.06.0-421-x86_64.rpm

3. Configuration and Startup

Use systemd to manage the rstudio-server service.

Running status
sudo systemctl status rstudio-server.service
● rstudio-server.service - RStudio Server
     Loaded: loaded (/usr/lib/systemd/system/rstudio-server.service; enabled; vendor preset: disabled)
     Active: active (running) since Thu 2020-10-22 20:37:02 CST; 1h 54min ago
    Process: 966 ExecStart=/usr/libexec/rstudio/bin/rserver (code=exited, status=0/SUCCESS)
   Main PID: 986 (rserver)
      Tasks: 3 (limit: 19067)
     Memory: 63.8M
        CPU: 2.198s
     CGroup: /system.slice/rstudio-server.service
             └─986 /usr/libexec/rstudio/bin/rserver

Oct 22 20:37:02 server systemd[1]: Starting RStudio Server...
Oct 22 20:37:02 server systemd[1]: Started RStudio Server.
Not-running status
sudo systemctl status rstudio-server.service
● rstudio-server.service - RStudio Server
     Loaded: loaded (/usr/lib/systemd/system/rstudio-server.service; enabled; vendor preset: disabled)
     Active: inactive (dead) since Thu 2020-10-22 22:34:05 CST; 1s ago
    Process: 966 ExecStart=/usr/libexec/rstudio/bin/rserver (code=exited, status=0/SUCCESS)
    Process: 6034 ExecStop=/usr/bin/killall -TERM rserver (code=exited, status=0/SUCCESS)
   Main PID: 986 (code=killed, signal=TERM)
        CPU: 2.246s

Oct 22 20:37:02 server systemd[1]: Starting RStudio Server...
Oct 22 20:37:02 server systemd[1]: Started RStudio Server.
Oct 22 22:34:05 server systemd[1]: Stopping RStudio Server...
Oct 22 22:34:05 server systemd[1]: rstudio-server.service: Succeeded.
Oct 22 22:34:05 server systemd[1]: Stopped RStudio Server.
Oct 22 22:34:05 server systemd[1]: rstudio-server.service: Consumed 2.246s CPU time.

Some useful systemd commands:

sudo systemctl start rstudio-server.service # start
sudo systemctl stop rstudio-server.service # stop
sudo systemctl enable rstudio-server.service # enable on boot
sudo systemctl disable rstudio-server.service # disable on boot

4. Accessing RStudio Server from a Browser

On another machine on the same network, open a browser and go to http://server_ip:8787 to access it.

local_login

After entering your username and password, you’re ready to work:

web_gui

For mobile broadband, even without a public IPv4 address, you may well have a public IPv6 address. Just visit http://[server_ipv6]:8787. Note that you generally need to connect your desktop directly to the mobile fiber modem, rather than going through a router.

Besides accessing it directly over a mobile carrier’s public IP, you can also use SSH or Cloudflare Zero Trust for reverse intranet access. See here for details.

5. Summary

This article covered installing RStudio Server and accessing it remotely.