GlassFish does not have built-in support for PHP. Actually it can support PHP if a Java implementation of PHP exists for GlassFish. This was made available by Quercus Caucho at http://quercus.caucho.com/. Download the binaries and source of Quercus from the site.
Assuming that GlassFish is installed and its directory path is represented as “glassfish”, proceed with the following steps -
- Extract the contents of the archive downloaded from the Quercus Caucho website
- Copy quercus.jar, resin-util.jar and script-10.jar from the WEB-INF/lib directory which is obtained from extracting the zip file to glassfish/lib directory
- Open the file glassfish/domains/domain1/config/default-web.xml and add the following lines
- Though the above lines of code seem to very complex, they can be simply interpreted as follows -
The first set of code indicates that there is a servlet available under the name Quercus Servlet and the second set of code indicates that the servlet is to be run whenever a file with php extension is encountered