Installation of the Server Version

This document outlines the setup of the server version of Rpad on Linux using Apache 2.4. The Perl portion of the Rpad interface can be installed using CGI or mod_perl.

The main steps to installing Rpad on a server are:

LoadModule cgi_module modules/mod_cgi.so
<Directory /var/www/Rpad/server*>  
  Options +ExecCGI
  AddHandler cgi-script .pl
  <IfModule mod_expires.c>
    ExpiresActive on
    ExpiresDefault "now plus 0 seconds"
  </IfModule>
</Directory>
AddType text/html .Rpad
LoadModule perl_module modules/mod_perl.so
<Directory /var/www/Rpad/server*>  
  <IfModule mod_perl.c>
    <Files *.pl> # requires mod_perl
      SetHandler perl-script
      PerlResponseHandler ModPerl::Registry
      PerlOptions +ParseHeaders
      Options +ExecCGI
    </Files>
  </IfModule>
  <IfModule mod_expires.c>
    ExpiresActive on
    ExpiresDefault "now plus 0 seconds"
  </IfModule>
</Directory>
AddType text/html .Rpad

Additional Notes

I normally add a cron job to restart the Apache server once a day. This clears out any R processes that didn't get killed for whatever reason. I create the following as the file /etc/cron.daily/Rpad-cleanup:

   apachectl restart
   rm -rf /var/www/Rpad/server/dd*

Some considerations for Windows:

# Used R's png driver rather than ghostscript: in RpadStartup.R,
# uncommented the following line: 
# 
graphoptions(type="Rpng")

That was it. I had ghostscript installed, so the default 
graphoptions(type="pngalpha")
also worked.

On my system, a number of stranded Rterm.exe files built
up. Restarting apache didn't get rid of them. The task manager
wouldn't get rid of them either. So, I used the "process"
command downloaded from
http://www.beyondlogic.org/solutions/processutil/processutil.htm
to kill them as:
process -k Rterm.exe

You also probably need to lock down the file system. Apache
starting as a service has access to the whole file system.
You need to change the user for the apache service and 
set permissions for that user to prevent access to unwanted
parts of your hard drive. Google for "apache localsystem ntfs permissions".

Troubleshouting server installations

Look for directories named /var/www/Rpad/server/dd??????????/ (adjust as needed for your root directory). In those directories, do you see eps and png graphics files? Having the eps files but not the png files might indicate that ghostscript isn't working right. If the directories are not being created it indicates that the perl interface is not working right.

If Rpad code sections return something like the following in your browser, then perl or mod_perl is not set up right:

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<HTML><HEAD>
<TITLE>405 Method Not Allowed</TITLE>
</HEAD><BODY>
<H1>Method Not Allowed</H1>
The requested method POST is not allowed for the URL /Rpad/server/R_process.pl.<P>
<HR>
<ADDRESS>Apache/1.3.33 Server at tomshort Port 80</ADDRESS>
</BODY></HTML> 

In 'General Example', do you see the HTML table just below the "HTML(head(dataset))" line? If so, that suggests that R2HTML is installed correctly.

In an Rpad page, select an R input section. On the first line of one of these, insert "RpadURL()" and hit the calculate button or F9. It should come back with something like "/Rpad/server/ddNgkIdEnXNA". Does it? If it's pointing to the wrong place, the browser won't be able to find the graphics files. If this happened, the browser would be blank where the graphic was supposed to be.

Make sure the *.pl files in /var/www/Rpad/server/ are set to enable execution.

Check the apache (or other server) error logs for additional information (/var/log/apache/error.log on Debian).

To test out the perl portion of Rpad and the browser access, enter the following in your browser:

http://localhost/Rpad/server/Rpad_process.pl?command=login

This should return a directory name, something like ddqbwuyLueIL. This should make a directory of the same name in Rpad/server. Then take this directory name and make another url as follows (replace the ID=ddqbwuyLueIL with your actual directory name):

http://localhost/Rpad/server/R_process.pl?&ID=ddqbwuyLueIL&command=R_commands&R_commands=print('hello' )

This should return [1] "hello" to the browser. If that works, then your connection to R should be right.

If graphics appear locally but not on remote machines, it indicates a problem with finding the URL for the graphics files. You may have to modify the Rpad/RpadStartup.R to explicitly tell R where to find the graphics files, like:

assign("RpadDir", envir = Rpad:::.RpadEnv, gsub("c:/Inetpub/wwwroot","", getwd(), ignore.case = TRUE) )


Original author: by Tom Short, tshort@epri.com, Copyright 2005. EPRI, license: GNU GPL v2 or greater Last updated 2014-01-01 by Jeffrey Dick.