Running Your Own Webserver
1 Using a Mac or Linux computer to run R CGI programs
If you'd like to run your CGI programs on your own computer before
moving them over to the SCF computers where I can test them, it's
fairly easy to do on Mac or Linux systems. (If you've got Cygwin
installed on a Windows computer, you can find information for
setting things up here.)
2 Linux
First make sure that the apache2 program is installed on your
system. If you're already running a webserver, then you're all set.
After installing
the CGIwithR package in R, you'll need to copy two files from the
installation to your system's cgi area. These two files can be found in
/usr/local/lib/R/site-library/CGIwithR/cgi-bin, and they are
called R.cgi and .Rprofile. Copy these two files to
/usr/lib/cgi-bin. You can now add your R scripts to that same
directory and access them as http://localhost/cgi-bin/R.cgi/scriptname.cgi,
where scriptname.cgi is the name of your CGI script.
3 Mac
To activate the apache webserver that's part of Mac OS X, open the
System Preferences pane (through the Apple menu), and choose the
"Sharing" preference. Click on "Web Sharing" to start the webserver.
After installing the CGIwithR package in R, you'll need to copy
two files from the installation to your system's cgi area. These two files
can be found in /Library/Frameworks/R.framework/Version/Current/Resources/library/CGIwithR/cgi-bin, and they are called R.cgi and .Rprofile. Copy
these two files to /Library/WebServer/CGI-Executables.
In the file R.cgi, find the line that looks like this:
R_DEFAULT=/usr/local/bin/R
and change it to
R_DEFAULT=/usr/bin/R
You can now add your
R scripts to that same directory, and your HTML files in
/Library/Webserver/Documents.
You can then
access the html files as http://localhost/file.html where
file.html is the name of your html file, and the CGI files as
http://localhost/cgi-bin/R.cgi/scriptname.cgi, where scriptname.cgi is the
name of your CGI script.
File translated from
TEX
by
TTH,
version 3.67.
On 3 May 2011, 11:31.