Last active
April 13, 2021 21:46
-
-
Save briandconnelly/259e763bc16393773c80 to your computer and use it in GitHub Desktop.
Setup RStudio Server on a Google Compute Engine Instance (Debian)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Install RStudio Server on a Google Compute Engine instance running Debian | |
# Wheezy | |
CRAN_MIRROR='cran.rstudio.com' | |
pushd /tmp | |
# Install up-to-date version of R --------------------------------------------- | |
sudo apt-key adv --keyserver keys.gnupg.net --recv-key 381BA480 | |
sudo sh -c "echo 'deb http://$CRAN_MIRROR/bin/linux/debian wheezy-cran3/' >> /etc/apt/sources.list" | |
sudo apt-get update | |
sudo apt-get -y install r-base libcurl4-openssl-dev | |
# Set the default mirror and install some packages | |
sudo sh -c "echo 'options(repos=structure(c(CRAN=\"http://$CRAN_MIRROR/\")))' >> /etc/R/Rprofile.site" | |
sudo Rscript -e "install.packages(c('devtools', 'shiny', 'magrittr', 'dplyr', 'tidyr', 'ggplot2'))" | |
# Install RStudio Server ------------------------------------------------------ | |
wget http://ftp.us.debian.org/debian/pool/main/o/openssl/libssl0.9.8_0.9.8o-4squeeze14_amd64.deb | |
sudo dpkg -i libssl0.9.8_0.9.8o-4squeeze14_amd64.deb | |
rm libssl0.9.8_0.9.8o-4squeeze14_amd64.deb | |
sudo apt-get -y install gdebi-core | |
wget http://download2.rstudio.org/rstudio-server-0.98.1091-amd64.deb | |
sudo gdebi rstudio-server-0.98.1091-amd64.deb | |
rm rstudio-server-0.98.1091-amd64.deb | |
sudo sh -c "echo 'www-address=127.0.0.1' >> /etc/rstudio/rserver.conf" | |
sudo sh -c "echo 'auth-required-user-group=rstudio_users' >> /etc/rstudio/rserver.conf" | |
sudo sh -c "echo 'session-timeout-minutes=30' >> /etc/rstudio/rsession.conf" | |
sudo sh -c "echo 'r-cran-repos=http://cran.rstudio.com/' >> /etc/rstudio/rsession.conf" | |
sudo addgroup rstudio_users | |
# TODO: create users and add them to the rstudio_users | |
sudo /etc/init.d/rstudio-server restart | |
# Set up nginx for reverse proxying | |
sudo apt-get -y install nginx | |
sudo rm /etc/nginx/sites-enabled/default | |
sudo sh -c "echo 'server {\n\tlisten 80;\n\tlocation /rstudio/ {\n\t\trewrite ^/rstudio/(.*)$ /\$1 break;\n\t\tproxy_pass http://127.0.0.1:8787; \n\t\tproxy_redirect http://127.0.0.1:8787/ \$scheme://\$host/rstudio/;\n\t}\n}' > /etc/nginx/sites-enabled/rstudio" | |
sudo /etc/init.d/nginx restart | |
# Install other tools --------------------------------------------------------- | |
sudo apt-get -y install vim tmux git zsh ffmpeg pandoc texlive texlive-latex-extra texlive-xetex | |
popd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To create an instance named "rstudio" and run this script on startup: