Skip to content

Instantly share code, notes, and snippets.

@MarkEdmondson1234
Last active February 10, 2016 14:43
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MarkEdmondson1234/366d54b4639d19b41d15 to your computer and use it in GitHub Desktop.
Save MarkEdmondson1234/366d54b4639d19b41d15 to your computer and use it in GitHub Desktop.
Installation of R, Rstudio, OpenCPU on GCE Debain Wheezy image, details on how to in the blogpost http://markedmondson.me/run-r-rstudio-and-opencpu-on-google-compute-engine-free-vm-image
### r-installation-debain-wheezy
#### setup commands to setup R, RStudio and OpenCPU on a Google Compute Engine Wheezy instance
#### Mark Edmondson 29 June 2014
##
## No original work, all taken from these sources:
## https://github.com/jeroenooms/opencpu-deb/blob/master/build-on-debian.md
## https://support.rstudio.com/hc/communities/public/questions/200651456-RStudio-server-not-installable-on-Debian-Wheezy-just-released-this-week-
## http://cran.r-project.org/bin/linux/debian/README.html
# need to be sudo for all below
sudo -i
apt-get update
apt-get upgrade
# do this to avoid language warnings, run and select languages with spacebar
dpkg-reconfigure locales
#### Installations needed for opencpu
apt-get install apparmor-utils
## Edit /etc/default/grub to set:
## GRUB_CMDLINE_LINUX=" security=apparmor"
nano /etc/default/grub
update-grub
reboot
## log in again, set sudo status
sudo -i
## check apparmor works
aa-status
## need to backport Apache 2.4
apt-get purge apache2-*
apt-get autoremove --purge
echo "deb http://www.d7031.de/debian wheezy-experimental main" > /etc/apt/sources.list.d/apache-backport.list
apt-key adv --keyserver keyserver.ubuntu.net --recv-key 9EB5E8A3DF17D0B3
apt-get update
apt-get dist-upgrade
apt-get install apache2
##### Install R 3.01
apt-key adv --keyserver keyserver.ubuntu.net --recv-key 381BA480
echo "deb http://cran.r-project.org/bin/linux/debian wheezy-cran3/" > /etc/apt/sources.list.d/cran.list
apt-get update
apt-get upgrade
apt-get install git make devscripts apache2-dev apache2-mpm-prefork libapreq2-dev r-base-core r-base-dev
# install Rapache
git clone https://github.com/jeffreyhorner/rapache.git
cd rapache
debuild -us -uc
cd ..
dpkg -i libapache2*.deb
service apache2 restart
apt-get install r-base libapparmor-dev r-cran-rcpp libcurl4-openssl-dev xvfb xauth xfonts-base
# install openCPU
git clone https://github.com/jeroenooms/opencpu-deb
cd opencpu-deb/
debuild -us -uc
cd ..
dpkg -i opencpu-lib*.deb
dpkg -i opencpu-server*.deb
# Edit /etc/apparmor.d/opencpu-exec and comment-out or remove the line that starts with "signal"
# Edit /etc/apparmor.d/opencpu-main and comment-out or remove the line that starts with "signal"
nano /etc/apparmor.d/opencpu-exec
nano /etc/apparmor.d/opencpu-main
service apparmor restart
service opencpu restart
# Done! Navigate to http(s)://your.server.com/ocpu/
# install cache server
apt-get install nginx
dpkg -i opencpu-cache*.deb
##### Install Rstudio
# install backport of libcurl library
sudo apt-get install libcurl4-openssl-dev
wget http://ftp.dk.debian.org/debian/pool/main/o/openssl/libssl0.9.8_0.9.8o-4squeeze14_amd64.deb
dpkg -i libssl0.9.8_0.9.8o-4squeeze14_amd64.deb
# install gbedi to build RStudio
apt-get install gdebi-core
# download the latest version at http://www.rstudio.com/products/rstudio/download-server/
wget http://download2.rstudio.org/rstudio-server-0.98.945-amd64.deb
apt-get install debconf
sudo gdebi rstudio-server-0.98.945-amd64.deb
rstudio-server start
# Done! RStudio running on port 8787 (remember to open port via GCE interface)
# ...but maybe you would like to run Rstudio at /rstudio/ on port 80?
# edit /etc/apache2/site-enabled/000-default to include below:
#### <VirtualHost *:80>
####
#### ProxyPass /rstudio/ http://localhost:8787/
#### ProxyPassReverse /rstudio/ http://localhost:8787/
#### RedirectMatch permanent ^/rstudio$ /rstudio/
####
#### </VirtualHost>
nano /etc/apache2/sites-enabled/000-default
/etc/init.d/apache2 restart
## create a webpage to display at http(s)://your.server.ip/
## below creates homepage with links to the OpenCPU and RStudio installations
echo '<!doctype html><html><body><h1>R on Google Compute Engine</h1><ul><li><a href="./rstudio/">RStudio Server</a></li><li><a href="./ocpu/test/">OpenCPU</a></li></ul></body></html>' | sudo tee /var/www/html/index.html
Copy link

ghost commented Jan 20, 2015

Thks Mark; i needed Rstudio for a mooc (coursera / data toolbox).. With my chromebook, thas s the only way i completed this task ( tried by using crouton, then cloud 9 ..; spent 2 days and half a night .. Hopefulle your script was there

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment