Install R and RStudio server in Debian
This post introduces how to complie latest R for RStidio, and install RStudio Server in a Debian host.
1. Compile and Install R for RStudio
Install build dependencies:
$ sudo apt update
$ sudo apt build-dep r-base
Install optional packages:
The automatically tuned linear algebra software:
$ sudo apt install libatlas3-base
Or the multi-threaded OpenBlas library:
$ sudo apt install libopenblas-base
Download R source
Download R source from: https://cran.rstudio.com/src/base/R-4/
The latest R source is R-4.0.4, which was released at 2021-02-15.
$ export R_VERSION=4.0.4
$ curl -O https://cran.rstudio.com/src/base/R-4/R-${R_VERSION}.tar.gz
$ tar -xzvf R-${R_VERSION}.tar.gz
$ cd R-${R_VERSION}
Build and install R
$ ./configure --prefix=/opt/R/${R_VERSION} --enable-memory-profiling --enable-R-shlib
$ make
$ sudo make install
Note:
- Option –enable-R-shlib is required for RStudio/RStudio Server.
- Note: The directory specified after –prefix= will determine where R is installed to when executing the make install command.The directory will be created automatically.
If use the system BLAS libraries, rather than the R internal versions, will be used,
$ ./configure --prefix=/opt/R/${R_VERSION} --enable-memory-profiling --enable-R-shlib --with-blas --with-lapack
Verify R installation
Test that R was successfully installed by running:
$ /opt/R/${R_VERSION}/bin/R --version
2. Install open source RStudio Server
Simply execute the following commands:
$ sudo apt install gdebi-core
$ wget https://download2.rstudio.org/server/bionic/amd64/rstudio-server-1.4.1103-amd64.deb
$ sudo gdebi rstudio-server-1.4.1103-amd64.deb
Then the RStudio Server would be available at: http://<server-ip>:8787.
Note:
- RStudio will prompt for a username and password, and will authenticate the user by checking the server’s username and password database. A couple of notes related to user authentication:
- RStudio Server will not permit logins by system users (those with user ids lower than 100).
- credentials are encrypted using RSA as they travel over the network.
- You can manage users with standard Linux user administration tools like useradd, userdel, etc.
- Each user needs to be created with a home directory.
3. Configure RStudio Server
RStudio is configured by adding entries to two configuration files (note that these files do not exist by default so you will need to create them if you wish to specify custom settings):
/etc/rstudio/rserver.conf
/etc/rstudio/rsession.conf
After editing configuration files you should perform a check to ensure that the entries you specified are valid. This can be accomplished by executing the following command:
$ sudo rstudio-server verify-installation
Note that this command is also automatically executed when starting or restarting the server (those commands will fail if the configuration is not valid).
Please see more configuration details at the document Configuring the Server.