Quercus is Caucho Technology's 100% Java implementation of PHP 5. Ludo described the steps to deploy PHP web applications on GlassFish. Caucho has released a new version of Quercussince then. This blog entry is an update to the steps described earlier.

  1. First, PHP-enable GlassFish.
    1. Unjar quercus-3.1.1.warand copy the JAR files in "WEB-INF/lib" directory to "GLASSFISH_HOME/domains/domain/lib" directory. That's it! Although the original entry requires to copy the JARs in "GLASSFISH_HOME/lib/addons" directory but that didn't work.
  2. Create a PHP web application
    1. Create a new Web application project, lets say "hellophp", using NetBeans IDE and choose GlassFish as the server.
    2. Replace the contents of "web.xml" with the following fragment:

      <?xml version="1.0" encoding="UTF-8"?>
      <web-app xmlns="http://java.sun.com/xml/ns/javaee"
        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
        <description>Caucho Technology's PHP Implementation, Running on GlassFish Java EE 5</description>
          <servlet-name>Quercus Servlet</servlet-name>
          <servlet-name>Quercus Servlet</servlet-name>

      This will declare PHP engine as the servlet.
    3. Add a new page "index.php" in "Web pages" folder. The contents of the page are:

      echo "Hello World!";

      This page prints "Hello World!" on the browser and some configuration settings of PHP. The directory structure of the created project looks like:


      Notice, "index.jsp" is only a template file to get started with JSPs and "sun-web.xml" is GlassFish-specific deployment descriptor. These files are not required for this PHP application although it does not hurt to leave them in the webapp as well.
  3. Deploy the application by right-clicking on the project and selecting "Deploy Project". Your first PHP application in GlassFish is now deployed at "http://localhost:8080/hellophp/index.php".

Now that you have verified that your GlassFish is ready to host PHP applications, try the different applications that are described in Ludo's blog.

Technorati: php glassfish caucho quercus