Emmabuntus, Ubuntu, Derivate, Linux, Open Source BackTrack, Linux, distributions, Ubuntu, derivate, securuty, forensic VirtualBox, Linux, Ubuntu, Raring Ringtail synaptic, Ubuntu, Linux, software packages jwplayer, multimedia, Linux, Ubuntu, flash Meshlab, graphic, software, Ubuntu, open source, Linux Synapse, Linux, Ubuntu, raring, Quantal Gimp, Ubuntu, Linux FreeMind, Linux, open source Linux, infographic, history

rApache Web Application Development with R and Apache: Quick Install For Debia/Ubuntu (Chapter II).

Rapache is a simple tool for remotely managing and configuring an apache2 instance without having to hassle around through configuration files.

 

Rapache is a python + GTK tool that allows you to configure apache2 and all of its modules.


GPL'd, Its goal is to provide the user with a simple interface to facilitate the work to those who want to set up a web-server in a few clicks.

 

Rapache has been fixes, so it finally works again. please use last trunk revision.

 

2.2 Running make.

Running make with no target will build rApache. Use 'make install' to install. The following make targets are also available:

 

    itest will run apache within a single process. You should see a message on the output to point your browser to http://localhost:8181/index.html where you can test out your rApache build before it is installed. In order to stop apache, either type Control-C or Control-\.

rapache-vhost-detail

test will run apache in multi-process mode. Run 'make stop' to stop apache.
    stop will stop apache after it was started with 'make test'.
    valgrind will run apache with valgrind in single-process mode.
    debug will run apache with gdb in single-process mode. Besure to look for the lines that say, "Copy/paste the following line to gdb". You'll need the 'run -x -f ...' command to start apache within the debugger.

 

2.3 Quick Install for Debian/Ubuntu.

Run the following as root (changing VERSION to the latest release version) or use sudo before each command:

apt-get install r-base-dev apache2-mpm-prefork apache2-prefork-dev
wget http://www.rapache.net/rapache-VERSION.tar.gz
tar xzvf rapache-VERSION.tar.gz
cd rapache-VERSION
./configure
make
make install

 

3. Configuring rApache.

This chapter details what to put in your Apache server configuration file(s). If you install Apache from source, then you will only have to edit the main file httpd.conf. If you install from a binary distribution, chances are the configuration is split among multiple files, so you may want to research your distribution's config layout before making any changes.


3.1 R_module.

This is how Apache loads mod_R (must be placed first before any rApache directives):

# All Apache modules are loaded this way. The most important thing to
# remember is that the string "R_module" is case sensitive, so get it
# right in the config file.

 

LoadModule R_module           /apache/module/path/mod_R.so

LoadModule is an apache directive that links in object files that contain module structures. rApache's module structure is named "R_Module".

 

NOTE: When attempting to start apache2 on some UNIX systems, you may see an error message similar to this one:

 

apache2: Syntax error on line 186 of /etc/apache2/apache2.conf: Cannot load
/usr/lib/apache2/modules/mod_R.so into server: libR.so: cannot open shared
object file: No such file or directory

 

To fix this, you will want to instruct your run-time linker, ld.so, on where to find libR.so. The easiest way to do this is by adding the directory to the /etc/ld.so.conf file and re-running ldconfig as root. If you don't know the location you can easily find out by running:

$ R CMD config --ldflags
-L/usr/lib/R/lib -lR

In the output above, /usr/lib/R/lib is the directory you will want to place in /etc/ld.so.conf.


3.3 SetHandler r-info.

When configuring rApache for the first time, you may want to add the following directive to ensure that your system is working. It produces a report about R and Apache when you visit the url at /RApacheInfo. For production systems, you might want to leave it out.

 

# Prints out a nice report about R running within Apache
<Location /RApacheInfo>
SetHandler r-info
</Location>

View a sample here.


3.4 REvalOnStartup.

This directive takes one argument: a string containing R expressions to evaluate upon startup. Any number of these directives can appear throughout the config files, and they are evaluated in the global environment in the order they appear. Useful for setting options and loading libraries like so:

# Load required DBI and RMySQL packages

REvalOnStartup "library(DBI); library(RMySQL)"

 

3.5 RSourceOnStartup.

Sometimes you want to evaluate quite a bit of code on startup. Equivalent to calling source() in the global environment. Just like REvalOnStartup, these directives can appear anywhere in the config files and they are evaluated in the order that they appear.

 

# Configure system with startup file

RSourceOnStartup "/var/www/lib/R/startup.R"

 

3.6 R Handlers.

It's important to read through the following section carefully as it will easily cause the most confusion. You have two Apache directives, two rApache directives, and two SetHandler options to learn.


3.6.1 Difference in Location and Directory.

The Apache directives Location and Directory are used here to match up urls and files to R handlers. Certainly, Apache is very configurable and other directives exist to provide more fine-grained control over urls and files, but please refer to the Apache documentation for further info.

"Location" is used to define the behavior of url's that do not map to files on the filesytem. In rApache, they can be used to invoke an R handler. For instance, suppose we have set up rApache on the site example.com and added the following "Location" directive as in section 2.3:

<Location /Risneat>
    SetHandler r-info
</Location>

Then, the url http://example.com/Risneat will invoke the handler r-info, but that url doesn't map to any file on the filesystem.

"Directory" is used to define the behavior of files on the filesystem. In rApache, they can be used to evaluate files containing R expressions through an R handler like so:

# Any file under /var/www/brew is passed through the function brew located in
# the package brew
<Directory /var/www/brew>
    SetHandler r-script
    RHandler brew::brew
</Directory>

Suppose example.com's Apache DocumentRoot was /var/www/, then the file /var/www/brew/foo.html maps to the url http://example.com/brew/foo.html and is run throuh the R package brew.

 

If you liked this article, subscribe to the feed by clicking the image below to keep informed about new contents of the blog:

rss_trappola

Do you consider this article interesting? Share it on your network of Twitter contacts, on your Facebook wall or simply press "+1" to suggest this result in searches in Google, Linkedin, Instagram or Pinterest. Spreading content that you find relevant helps this blog to grow. Thank you!
Share on Google Plus

About Hugo

Ubuntu is a Linux distribution that offers an operating system predominantly focused on desktop computers but also provides support for servers. Based on Debian GNU / Linux, Ubuntu focuses on ease of use, freedom in usage restriction, regular releases (every 6 months) and ease of installation.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment