how to install and configure and run RStudio server in Debian
Installing and configuring RStudio Server on a Debian-based system involves several steps. Below is a detailed guide to help you through the process:
First, ensure your system is up to date by running the following commands:
sudo apt update
sudo apt upgrade
RStudio Server requires R to be installed on your system. You can install R by adding the CRAN repository and then installing R:
sudo sh -c 'echo "deb https://cloud.r-project.org/bin/linux/debian $(lsb_release -cs)-cran40/" >> /etc/apt/sources.list'
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 51716619E084DAB9
sudo apt update
sudo apt install r-base
Download the RStudio Server .deb package from the RStudio website. You can find the latest version here.
wget https://download2.rstudio.org/server/bionic/amd64/rstudio-server-1.4.1717-amd64.deb
sudo dpkg -i rstudio-server-1.4.1717-amd64.deb
sudo apt --fix-broken install
Start the RStudio Server service and enable it to start on boot:
sudo systemctl start rstudio-server
sudo systemctl enable rstudio-server
The main configuration file for RStudio Server is located at /etc/rstudio/rserver.conf
. You can edit this file to configure various settings.
For example, to change the default port (8787), you can add the following line:
www-port=8787
After making changes to the configuration file, restart the RStudio Server service:
sudo systemctl restart rstudio-server
Open a web browser and navigate to http://<your-server-ip>:8787
. You should see the RStudio Server login page.
RStudio Server uses system user accounts for authentication. You can create a new user account with the following command:
sudo adduser <username>
Follow the prompts to set the password and other details for the new user.
Use the newly created user account to log in to RStudio Server through the web interface.
To secure your RStudio Server with SSL, you can use a reverse proxy like Nginx or Apache. Here is a basic example using Nginx:
sudo apt install nginx
/etc/nginx/sites-available/rstudio
:server {
listen 80;
server_name your_domain_or_ip;
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 "upgrade";
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;
}
}
sudo ln -s /etc/nginx/sites-available/rstudio /etc/nginx/sites-enabled/
sudo systemctl restart nginx
That's it! You should now have RStudio Server up and running on your Debian system.