OK, first things first Apache is NOT Apache Tomcat. They are two separate products. Whilst both products fall under the Apache “umbrella”, and their internal workings are very similar they are, in fact, different products.
Apache HTTP Server
(Versions 2.0 – 2.2 )
Web applications for Tomcat are stored in $CATALINA_HOME\webapps and conversely
Web applications for Apache are stored in $CATALINA_HOME \htdocs
Tomcat often refers to $CATALINA_HOME, which simply translates to the home directory in which Tomcat was installed.
Unlike IIS, Apache HTTP Server doesn’t really come with a nice looking GUI front end, instead most configuration is done in config files.
For Apache this is : \conf\httpd.conf
And for Tomcat this is : \conf\server.xml
However Apache Tomcat comes with some GUI web based front ends.
These are associated with the tomcat-users.xml file.
Web Configuration Files
Apache Tomcat also uses a web.xml in addition to server.xml. Web.xml configures specifics for each WEBAPP, defining parameters in $CATALINA_HOME\conf\web.xml cascades to ALL web applications. Individual applications can have their own web.xml located in $CATALINA_HOME \WEBAPPS\$APP_NAME\WEB-INF\web.xml. These will override the default web.xml settings.
Adding New Web Applications
Unlike Apache, Tomcat requires that you “install” your application. To do this you need to access the Tomcat Web Application Manager, and under the “install” section enter the url of your webapp and hit install.
Download latest collection of PECL modules
Unzip php 5.x zip file anywhere, normally c:\php
Copy php.ini-dist, in c:\php, as php.ini
Uncomment the line (remove semi-colon at the beginning) in php.ini:
Extract php5servlet.dll from pecl zip file to c:\php (Uncheck "Use Folder Names" in WinZip).
Ensure that the file is actually present in c:\php
Install Tomcat and create a directory under webapps. Lets say it is named fun.
Create WEB-INF directory under fun
Create lib directory under WEB-INF
Create web.xml under WEB-INF with the following contents:
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
Extract php5srvlt.jar and extract/unjar (jar xvf …) it under c:\
Modify both the files in c:\net\php\reflect.properties and servlet.properties to change the line library=phpsrvlt to library=php5servlet and save them. This indicates the file name of the dll file which is loaded by the Java application to serve the requests. In my version the name of the dll was php5servlet.dll. Your mileage may vary. This has no connection with the name of the jar file which can be anything.
Re-create the jar file
Copy the jar file to WEB-INF\lib directory created earlier
Add c:\php to your System or User Path in Windows enironment (Hint: Right-click and select Properties from My Computer)
Create a file test.php under fun with the following code:
Start Tomcat (Go to [Tomcat installation directory]\bin and type Tomcat).
Open your browser and go to http://localhost:8080/fun/test.php
Ensure that there are no errors displayed. Instead you get an informative screen with php version information and whole lot of details
Another article detailing a method to get PHP running on Tomcat is located here :
Tomcat works on various Java libraries (.jar). These can be located globally under $CATALINA_HOME \common\lib\ or locally under $CATALINA_HOME \WEBAPPS\$APP_NAME\WEB-INF\lib\
Apache HTTP Server
To enable PHP in Apache
Firstly locate the httpd.conf file in $CATALINA_HOME\conf
Then simply add
# Added for php support