Using PHP With Tomcat

This page describes how to use PHP (v4) with Tomcat (v4 or later). The contents were originally written and sent to the tomcat-dev list by Jean-Frederic Clere (on his vacation, no less (wink) ) and Henri Gomez.


Prerequisites

Configure and make PHP Installation:

Copy jar to your webapp's or tomcat's common class repository:

Declare PHP servlet and servlet-mapping in your or tomcat's common web.xml:

Modify your LD_LIBRARY_PATH to include the dynamic library produced in step 1 above:

Start tomcat:


Testing


Patch for PHP configure Script

This is a patch for PHP's configure script to account for the servlet jar name change (from servlet.jar in Servlet Spec 2.3 and previous \[tomcat 4 and previous\] to servlet-api.jar in Servlet Spec 2.4 and above \[tomcat 5 and later\]):

— configure.org 2004-04-07 11:20:24.000000000 +0200
+++ configure 2004-04-07 11:22:50.000000000 +0200
if test "$withval" = "yes"; then
SERVLET_CLASSPATH=.
else
+ if test -f $withval/common/lib/servlet-api.jar; then
+ SERVLET_CLASSPATH=$withval/common/lib/servlet-api.jar
+ fi
+
if test -f $withval/lib/servlet.jar; then
SERVLET_CLASSPATH=$withval/lib/servlet.jar
fi
++++