Drupal
In July, 2007, Geert Bevin experimented with clustering Drupal with Terracotta running on Caucho's Quercus
, a Java implementation of PHP.
This is the current state of things:
- Resin launches another Java process that runs the actual web server, this means that resin.conf needs to be modified to actually use Terracotta with the servlet container.
- By default Resin replaces the system classloader. This seems to go into an endless loop when used with Terracotta. I didn't go
through it step by step to find the exact cause yet though. Attached is a patch that disables this system classloader entirely, which seems to work. Some features of Resin are most probably disabled due to this, we haven't investigated what exactly though.
- Using Ehcache as a Quercus module and changing the Drupal cache handling makes it possible for Terracotta to cluster the Drupal cache entries.
Anyway, with this, Drupal is using Ehcache which is clustered through Terracotta ... though very hackishly due to non existent Resin support.
Attached are some diffs, the tc-config Geert was using, and a Quercus module that allows Ehcache to be used from within PHP.
How to get this to work
Disable Resin's SystemClassLoader
- get the attached ResinWatchdog.java.diff
file
- get the Resin 3.1.2 source from their download page

- extract the archive to obtain the resin-3.1.2 directory
- retrieve activation.jar and javamail-14.jar from somewhere (for instance from the lib dir of Resin's binary distribution
)
- make sure you have Apache Ant
installed and in your execution path
- perform the following commands:
Install Drupal in Resin
- get Drupal 5.2 from their download page

- extract the archive to obtain the drupal-5.2 directory
- perform the following commands inside the resin-3.1.2 directory:
Install Ehcache and its Quercus module
Change Drupal's cache handle to use the Ehcache module
- get the attached cache.inc.diff
file
- perform the following commands inside the resin-3.1.2 directory:
Enable mail delivery in Drupal
- go to the directory resin-3.1.2/webapps/drupal/WEB-INF/ and create a new file, called resin-web.xml
- open resin-web.xml in a text editor and add the following content:
<web-app xmlns="http://caucho.com/ns/resin">
<servlet-mapping url-pattern="*.php"
servlet-class="com.caucho.quercus.servlet.QuercusServlet">
<init>
<php-ini>
<sendmail_from>youraddress@domain.com</sendmail_from>
<SMTP>your.smtp.server</SMTP>
</php-ini>
</init>
</servlet-mapping>
</web-app>
Setup Drupal
- decide which database you want to use, PostgreSQL or MySQL
- get the appropriate JDBC driver (for PostgreSQL
, for MySQL
)
- install the JDBC jar by performing the following commands inside the resin-3.1.2 directory:
- create a dedicated database and user, for instance like this for PostgreSQL:
- perform the following commands inside the resin-3.1.2 directory to start Resin:
- visit the Drupal setup page at http://localhost:8080/drupal
and provide the details of the database you just created
- after you submit the form, you'll see the same empty form again, this seems weird but don't fred, the form just changed the values of a configuration file, you now need to install the database structure for real
- put the cursor focus on your browser's location text field, and press enter to perform the actual installation of the database structure, or click here http://localhost:8080/drupal/install.php?profile=default

- visit http://localhost:8080/drupal
and start using Drupal
Enable Terracotta
- download the Terracotta distribution from our download section
- unzip or install it
- get the tc-config.xml
file that is attached to this page
- generate a bootjar for Drupal by performing the following command inside the terracotta installation directory:
- note the name of the JAR file that is created on your system, you'll need that, I'll refer to it later as the your/bootjar/location
- modify the Resin configuration to use Terracotta
- open resin-3.1.2/conf/resin.conf in a text editor
- locate the following XML termination tag:
- add the following tags before it and adapt them to your system's paths:
<jvm-arg>-Dcom.sun.management.jmxremote</jvm-arg>
<jvm-arg>-Dnet.sf.ehcache.useLRUMap=true</jvm-arg>
<jvm-arg>-Xbootclasspath/your/bootjar/location</jvm-arg>
<jvm-arg>-Dtc.install-root=your/terracotta/installation/dir</jvm-arg>
<jvm-arg>-Dtc.config=localhost:9510</jvm-arg>
- start the Terracotta server, by performing this inside your Terracotta installation dir:
- start Resin the usual way:
Notes
The ehcachemodule.jar contains both the sources as the compiled class files. If you unjar the archive, you can get at the source code of the Ehcache Quercus module for Drupal that I wrote and make changes if you need to do so.
Supporting files
ResinWatchdog.java.diff
cache.inc.diff
ehcachemodule.jar
tc-config.xml