Quercus: Tomcat

From Resin 3.0

Revision as of 21:43, 2 July 2009 by Nam (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Quercus is implemented primarily as a servlet and it will run in any application server including Tomcat.

Contents

Requirements

  1. Java 1.5 or higher
  2. Quercus WAR download at http://quercus.caucho.com

Optional

  1. MySQL Connector/J Driver
  2. Java Mail (javax.mail jar)

Quick start

The Quercus servlet is just a plain servlet. The web.xml should look like the following:

web.xml

<web-app 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"
   version="2.5">

  <display-name>Quercus on Tomcat</display-name>
  
  <servlet>
     <servlet-name>Quercus Servlet</servlet-name>
     <servlet-class>com.caucho.quercus.servlet.QuercusServlet</servlet-class>
  </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>

Compilation

Quercus can compile PHP files down to Java bytecodes for faster performance. However, this feature was only available when Quercus was running inside Resin. Since 4.0.1, this constraint no longer exists and Quercus compilation is now available to all application servers including Tomcat. A valid license is required.

Configuration

Quercus compilation requires a license. In the web.xml, you will need to specify the directory where the license is located:

<web-app 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"
   version="2.5">

  <display-name>Quercus on Tomcat</display-name>
  
  <servlet>
     <servlet-name>Quercus Servlet</servlet-name>
     <servlet-class>com.caucho.quercus.servlet.QuercusServlet</servlet-class>
     <init-param>
       <param-name>license-directory</param-name>
       <param-value>WEB-INF/licenses</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>

The compiled files will be located in WEB-INF/work.

Personal tools