Sunday, February 01, 2009

Quercus PHP 3.2.1 on GlassFish 2.1

I am trying to consolidate a number of applications running on various platforms to GlassFish, if possible. So far I have been incredibly successful with Ruby using JRuby. Our project tracking software (bugs/news/wiki/forums/repository browser) are running on Redmine using JRuby.

Based on the success of using Ruby (RoR), I decided to trying moving some PHP applications over to GlassFish.

I read a great blog article by Ludovic Champenois called 100% Java Quercus PHP engine running in GlassFish Java EE 5 Application Server It describes how to use an open source engine called Quercus from Caucho. I tried to follow the directions, but could not get it to work. I imagine because the versions of GlassFish application server and Quercus may have been different. I was not deterred.

I came across a follow-up article by Arun Gupta called PHP in GlassFish using Caucho Quercus. This article was the missing link. The major difference being the placement of the jar files in the domain/domainXX/lib directory.

Here are the application versions I used to get a functional Caucho Quercus PHP implementation running on GlassFish v 2.1

Mac OS X 10.5.6 (Intel x86)

  • GlassFish v 2.1 Build 60e ( 2.1 FCS)
  • Quercus 3.2.1
  • Java(TM) SE Runtime Environment (build 1.6.0_07-b06-146) Java HotSpot(TM) 64-Bit Server VM (build 1.6.0_07-b06-56, mixed mode)

Mac OS X 10.5.6 (PowerPC)

  • GlassFish v 2.1 Build 60e ( 2.1 FCS)
  • Quercus 3.2.1
  • jsr223-api.jar (Project Phobos) Required for Java SE 5.
  • Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_16-b06-284) Java HotSpot(TM) Client VM (build 1.5.0_16-133, mixed mode, sharing)
When I created my projects I used the following web.xml It is based on the example web.xml in the Quercus 3.2.1 war file.

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<session-config>
   <session-timeout>
       30
   </session-timeout>
</session-config>

<description>Caucho Technology's PHP Implementation</description>
<servlet>
   <servlet-name>Quercus Servlet</servlet-name>
   <servlet-class>com.caucho.quercus.servlet.QuercusServlet</servlet-class>
<!-- Specifies the encoding Quercus should use to read in PHP scripts.
    -->
<!--
    <init-param>
      <param-name>script-encoding</param-name>
      <param-value>UTF-8</param-value>
    </init-param>
    -->

<!-- Tells Quercus to use the following JDBC database and to ignore the
         arguments of mysql_connect().
    -->
<!--
    <init-param>
      <param-name>database</param-name>
      <param-value>jdbc/test</param-value>
    </init-param>
    -->

<!--
    <init-param>
      <param-name>ini-file</param-name>
      <param-value>WEB-INF/php.ini</param-value>
    </init-param>
    -->
</servlet>

<servlet-mapping>
   <servlet-name>Quercus Servlet</servlet-name>
   <url-pattern>*.php</url-pattern>
</servlet-mapping>
<welcome-file-list>
   <welcome-file>index.php</welcome-file>
</welcome-file-list>
</web-app>


This arrangement will allow you run a large number of applications including XWiki, and Drupal. Unfortunately for me, it can not run phpLDAPadmin which I needed.

5 comments :

Walking on the Wildsidea said...

How was the performance?

pelegri said...

Hi John. Thanks for the report. I've been thinking of ways that GlassFish users with common interests can help each other. In this case with Quercus / PHP. The current thought it that we would create a "home" page in a Wiki for each key technology, assign an owner, and keep it up-to-date.

John Yeary said...

The performance was quite good, but I am only providing a subjective view. I don't have any numbers to back it up. I would note that it takes a lot less time to load on Glassfish than Apache 2.

Again that is subjective.

John Yeary said...

pelegri, I think that is a great idea. I would add my notes and remarks to it.

Where were you planning on adding it? Perhaps on the Aquarium?

garry.donnelly said...

Great post - thanks! I've performed a similar install with the latest Glassfish and Quercus which seems to be running very well and doesn't require the php to be encased in a war. :o) I wrote the up the details here: http://www.greatwhiteit.com/blog/?p=1

-Garry

Popular Posts