rApache on Debian 6.0 squeeze or Ubuntu 10.04 Lucid Lynx

This is how I installed and configured rApache on Debian 6.0 (squeeze). It should work on Ubuntu 10.04 Lucid Lynx also.

Install R and Apache MPM prefork (I assume that Apache 2 is installed already):

> sudo aptitude install r-base r-base-dev apache2-mpm-prefork apache2-prefork-dev

Download and build rApache from source:

> cd /usr/local/src
> sudo wget http://biostat.mc.vanderbilt.edu/rapache/rapache-1.1.17.tar.gz
> sudo tar xzf rapache-1.1.17.tar.gz
> cd rapache-1.1.17
> sudo ./configure
> sudo make
> sudo make install

Create file /etc/apache2/mods-available/R.load with content:

LoadModule R_module /usr/lib/apache2/modules/mod_R.so

Enable mod_R:

> sudo a2enmod R

Create folder /var/www/r-scripts .

Add the following to /etc/apache2/sites-available/default inside <VirtualHost *:80>:

<VirtualHost *:80>
	...
	<Directory /var/www/r-scripts/>
		SetHandler r-script
		RHandler sys.source
	</Directory>
	...
</Directory>

Created file /var/www/r-scripts/hello.R with the following content:

setContentType(type='text/plain')
cat('Hello')
DONE

Restart Apache:

> sudo /etc/init.d/apache2 restart

Verify that it works:

> curl -s http://localhost/r-scripts/hello.R
Hello

Done.

References:

Apache Server, Tomcat and mod_jk on Debian 6.0 squeeze

This is how I integrated Tomcat 6 with Apache 2 on Debian 6.0 (squeeze) using mod_jk. It should also work on Ubuntu 10.04 Lucid Lynx.

Install Apache Web Server:

> aptitude install apache2

Verify that the server is running:

> curl -s http://localhost | grep "It works"
<html><body><h1>It works!</h1>

Install Tomcat (you don’t need to install tomcat6-examples, I did it only for the purpose of this How To):

> aptitude install tomcat6 tomcat6-examples

Verify that Tomcat server is running:

> curl -s http://localhost:8080 | grep "It works"
<h1>It works !</h1>

Install mod_jk:

> aptitude install libapache2-mod-jk

Create file /etc/apache2/workers.properties with the following content:

worker.list=worker1
worker.worker1.type=ajp13
worker.worker1.host=localhost
worker.worker1.port=8009

Create file /etc/apache2/mods-available/jk.conf with the following content:

JkWorkersFile	/etc/apache2/workers.properties
JkShmFile	/var/log/apache2/mod_jk.shm
JkLogFile	/var/log/apache2/mod_jk.log
JkLogLevel	info

Enable jk conf:

> a2enmod jk

Add mount point to /etc/apache2/sites-available/default:

<VirtualHost *:80>
	...
	JkMount		/examples/* worker1
	...
</VirtualHost>

Uncomment the following line in /etc/tomcat6/server.xml:

<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />

Restart Tomcat:

> /etc/init.d/tomcat6 restart

Restart Apache web server:

> /etc/init.d/apache2 restart

Now verify that everything works:

> curl -s http://localhost/examples/ | grep "Tomcat Examples"
<H3>Apache Tomcat Examples</H3>

Done.

References: