You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

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.

Using php in Tomcat5: Easy a servlet is available in php (I have tried with php-4.3.5)


configure the php with:
./configure --with-servlet=$TOMCAT_HOME --with-java=$JAVA_HOME a jarfile and dynamic library are produced:

  • sapi/servlet/phpsrvlt.jar
  • libs/libphp4.so

Copy jarfile and arrange web.xml:
cp $PHP_HOME/sapi/servlet/phpsrvlt.jar $TOMCAT_HOME/common/lib copy the $PHP_HOME/sapi/servlet/web.xml servlet and servlet-mapping in the
$TOMCAT_HOME/conf/web.xml

Start the Tomcat:
LD_LIBRARY_PATH=$PHP_HOME/libs export LD_LIBRARY_PATH
$TOMCAT_HOME/bin/catalina.sh start

Try it:
Create a file named ./webapps/ROOT/test.php containing:
+++
<?php phpinfo(); ?>
+++
Call it: http://localhost:8080/test.php

Patch for the configure of php:

— 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
++++

  • No labels