Steps for running PHP (version 5) with Apache Tomcat 6 Server on Localhost

One of our readers Mr. Nutan Vishwakarma did some studies on how to run PHP with Apache Tomcat 6 Server. Lets see what he has to say..

Simple Steps for running PHP (version 5) with Apache Tomcat 6 Server on Localhost :

1. Download & Unzip PHP (5.2.6) to a directory, c:\php-5.2.6-Win32
(download location http://www.brothersoft.com/php-68222.html)

2. Download PECL 5.2.5 Win32 binaries
(download location http://www.filewatcher.com/m/pecl-5.2.5-Win32.zip.2948387.0.0.html)

3. Rename php.ini-dist to php.ini in c:\php-5.2.6-Win32

4. Add extension=php_java.dll in Dynamic Extensions section in php.ini

5. Extract php5servlet.dll from PECL 5.2.5 to c:\php-5.2.6-Win32

6. Extract php_java.dll from PECL 5.2.5 to c:\php-5.2.6-Win32\ext

7. Create a directory named forphp (any name you like) in tomcat\webapps directory.

8. Extract phpsrvlt.jar from PECL 5.2.5 to tomcat\webapps\forphp\WEB-INF\lib

9. Unzip phpsrvlt.jar

10. Modify both net\php\reflect.properties and net\php\servlet.properties to library=php5servlet

11. Pack phpsrvlt.jar

12. Create web.xml in tomcat\webapps\forphp\WEB-INF as following:

<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance "
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd ">
<servlet>
<servlet-name>php
<servlet-class>net.php.servlet
</servlet>
<servlet>
<servlet-name>php-formatter
<servlet-class>net.php.formatter
</servlet>
<servlet-mapping>
<servlet-name>php
<url-pattern>*.php
</servlet-mapping>
<servlet-mapping>
<servlet-name>php-formatter
<url-pattern>*.phps
</servlet-mapping>
</web-app>

13. Add php path to the system variable named path

14. Create phptest.php for testing under tomcat\webapps\forphp as following

<?php phpinfo(); ?>

15. Startup tomcat

16. Visit http:\\localhost:8080\forphp\phptest.php
(You should see php info if everything works properly)

Thanks for Reading my POST.

References :
http://www.softminer.net/2009/05/how-to-install-or-run-php-on-tomcat-6.html