Setting up FastRWeb on Mac OS X

[This article was first published on Rronan » R, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

FastRWeb is an infrastructure that allows any webserver to use R scripts for generating dynamic content, such as web pages and graphics.

In this post, you’ll learn how to install and set up FastRWeb on a Mac. This tutorial is expendable to any Unix-like operating system. It is an adaptation from Jay Emerson’s post, Setting up FastRWeb/Rserve on Ubuntu.

References

Configuration

Even if not required, I recommend installing the latest version of the XML package. An older version may cause a dysfonction. You should install it from sources.

ftp http://www.omegahat.org/RSXML/XML_3.93-0.tar.gz
R CMD INSTALL XML_3.93-0.tar.gz

Cairo is a graphics device for R which uses the cairo graphics library. You can easily install it using MacPorts or Fink. In the terminal, install Cairo from sources.

ftp http://www.rforge.net/Cairo/snapshot/Cairo_1.5-1.tar.gz
R CMD INSTALL Cairo_1.5-1.tar.gz

I use the Apache HTTP Server from XAMPP because it comes pre-configured to run CGI scripts. You may want to use the server pre-installed on Mac OS X. Then, you will have to configure it to run CGI scripts.

Installing Rserve

To install Rserve, you have to use a recent version of R (≥ 2.0.0). As the other packages, you should install it from sources.
You will need administrator privileges to install it.

ftp http://www.rforge.net/Rserve/snapshot/Rserve_1.7-0.tar.gz
sudo R CMD INSTALL Rserve_1.7-0.tar.gz

If the installation is okay, try to run Rserve in R.

require(Rserve)
Rserve()

Installing FastRWeb

As the other packages…

ftp http://www.rforge.net/FastRWeb/snapshot/FastRWeb_1.1-0.tar.gz
sudo R CMD INSTALL FastRWeb_1.1-0.tar.gz

FastRWeb isn’t a simple R package, it is an environment for servers to run R scripts. To do this, you must go to the folder where is the FastRWeb package.

cd `echo 'cat(system.file(package = "FastRWeb"))' | R --slave`

FastRWeb privides a sample script install.sh that sets up the environment. You can run it like this:

sudo sh install.sh

FastRWeb will be installed in /var/FastRWeb/.

Now you can copy the CGI program named Rcgi which is in the directory cgi-bin of the package to the directory cgi-bin of the server. You’ll have to use the administrator privileges.

sudo cp cgi-bin/Rcgi /Applications/XAMPP/xamppfiles/cgi-bin/R

Starting the server

Now, you can run the Apache HTTP Server with XAMPP Control.

open -a /Applications/XAMPP/XAMPP\ Control.app

Start Rserve with the administrator privileges.

sudo /var/FastRWeb/code/start

Try the example

There are examples of R scripts in /var/FastRWeb/web.R/. You can try them here:
http://localhost/cgi-bin/R/example1.png
http://localhost/cgi-bin/R/example2

If you can see the examples, you can start developping your own scripts.

Stopping Rserve

To stop FastRWeb/Rserve.

sudo killall -INT Rserve

Removing sources

You may want to remove sources.

rm XML_3.93-0.tar.gz Cairo_1.5-1.tar.gz Rserve_1.7-0.tar.gz FastRWeb_1.1-0.tar.gz

Licence Creative Commons

To leave a comment for the author, please follow the link and comment on their blog: Rronan » R.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)