UPDATE APRIL 2011:
This is an old post and as such is not current for PHP or Tomcat as they are today. Please do not follow this post's instructions as they are now likely out of date.
More current information can be found at
I would in fact now recommend simply running Quercus PHP:
Sometimes, you want to run PHP
. Why? Well, you may have a legacy
product, for instance, that will require servlets for many more years. Or you may be using this gigantic Java program and are only interested in adding a tiny PHP piece on the side.
There are many guides showing how to do this available, but they become outdated almost as soon as they are published. So, it's my turn to write a short-lived guide, this time for PHP 5.2.5 :)
Note thas this post relies greatly on information found here. Too bad even that guide got old so fast!
- Go to http://www.php.net/downloads.php and download the current version. I am going to do the setup on a Windows machine here, so I can simply download the binaries. On *nix, you will need to compile PHP. I know I will have to, anyway...
- You also need to download the corresponding PECL modules.
- Let's assume that your current Tomcat install can be found in c:Tomcat5. Create a c:Tomcat5php directory and unzip the PHP zip file in it.
- Rename php.ini-dist, in c:Tomcat5php, to php.ini
- Extract php5servlet.dll from the PECL zip file to c:Tomcat5php
- Create a directory under c:Tomcat5webapps; in our case: phptest
- In c:Tomcat5webappsphptest, create a subdirectory: WEB-INF
- In c:Tomcat5webappsphptestWEB-INF, create web.xml with the following content:
- Extract/unjar (using jar xvf or WinZip) php5srvlt.jar under c:Tomcat5phptmp
- Modify both c:Tomcat5phptmpnetreflect.properties and c:Tomcat5phptmpnetservlet.properties, replacing
- Jar the content of c:Tomcat5phptmp into a new version of php5srvlt.jar
- Move php5srvlt.jar to c:Tomcat5commonlib
- Copy c:Tomcat5phpphp5servlet.dll and c:Tomcat5phpphp5ts.dll to c:windowssystem32
- Create a test page in c:Tomcat5webappsphptesttest.php with this contents:
- Start Tomcat and go to http://localhost:8080/phptest/test.php
It should work. If it doesn't, you can always post the stack trace
Share on Facebook