Dashboard > Terracotta Public Wiki > Home > Drupal
  Terracotta Public Wiki Log In   View a printable version of the current page.  
  Drupal
Added by Orion Letizi, last edited by Geert Bevin on Aug 02, 2007  (view change)
Labels: 
(None)

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:
    $ unzip resin-3.1.2
    $ cd resin-3.1.2
    $ patch -p0 < path/to/ResinWatchdog.java.diff
    patching file modules/resin/src/com/caucho/boot/ResinWatchdog.java
    $ mkdir modules/ext
    $ cp path/to/activation.jar path/to/javamail-14.jar modules/ext
    $ ant
    ... lots of output ...
    BUILD SUCCESSFUL
    Total time: 47 seconds
    

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:
    $ mv path/to/drupal-5.2 resin-3.1.2/webapps/drupal
    

Install Ehcache and its Quercus module

  • get the attached ehcachemodule.jar file
  • get Ehcache 1.3.0 from their download page
  • extract the archive to obtain the ehcache-1.3.0 directory
  • retrieve jsr107cache-1.0.jar
  • retrieve commons-logging-1.0.3.jar
  • retrieve commons-collections-3.2.jar
  • perform the following commands inside the resin-3.1.2 directory:
    $ mv path/to/ehcachemodule.jar lib
    $ mv path/to/ehcache-1.3.0/ehcache-1.3.0.jar lib
    $ mv path/to/jsr107cache-1.0.jar lib
    $ mv path/to/commons-logging-1.0.3.jar lib
    $ mv path/to/commons-collections-3.2.jar lib
    

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:
    $ cd webapps/drupal/
    $ patch -p0 < path/to/cache.inc.diff
    

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:
    $ cp path/to/yourjdbc.jar lib
    
  • create a dedicated database and user, for instance like this for PostgreSQL:
    $ sudo su - postgres
    $ createuser --pwprompt --encrypted --no-adduser --no-createdb drupal
    Enter password for new role:
    Enter it again:
    Shall the new role be allowed to create more new roles? (y/n) n
    CREATE ROLE
    $ createdb --encoding=UNICODE --owner=drupal drupal
    CREATE DATABASE
    
  • perform the following commands inside the resin-3.1.2 directory to start Resin:
    $ sh bin/http.sh
    
  • 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:
    ./bin/make-boot-jar.sh path/to/tc-config.xml
    ... some output ...
    Successfully created boot JAR file at '/your/terracotta/installation/lib/dso-boot/dso-boot-xxxxx.jar'.
    
  • 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:
    </server-default>
  • 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:
    sh bin/start-tc-server.sh
    
  • start Resin the usual way:
    sh bin/http.sh
    

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

Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.5.5 Build:#811 Jul 25, 2007) - Bug/feature request - Contact Administrators