Installing & Running PHP in Tomcat

Here are steps to install and run php in tomcat server.

  1. Download and install latest java from Oracle http://www.oracle.com/technetwork/java/javase/downloads/index.html
  2. Set java_home in system classpath
  3. Download latest tomcat from “http://tomcat.apache.org/download-70.cgi” and unzip c:\tomcat
  4. Download latest php for window “http://windows.php.net/download/”and unzip to a directory, 
    c:\php
  5. Set path in you system  for php folder like
    path=%path%;c:\php
  6. Download latest PECL Win32 binaries from http://museum.php.net/php5/  like download  “pecl-5.2.5-Win32.zip”
  7. Download latest  PHP-JAVA Bridge war file from http://sourceforge.net/projects/php-java-bridge/files/Binary%20package/php-java-bridge_6.2.1/
  8. Go to you php installation folder c:\php and rename “php.ini-production” file to “php.ini” file
  9. Add the new line (If does not exist) in new php.ini:
    ;extension=php_java.dll
  10. Copy php5servlet.dll from PECL 5.2.5 to c:\php
  11. copy php_java.dll from PECL 5.2.5 to 
    c:\php\ext
  12. Copy downloaded ” JavaBridgeTemplate621.war” to tomcat\webapps folder and rename as php.war
  13. Now start tomcat and access you php-java bridge application and test your php file “http://localhost:8080/php/
  14. If you are creating any php file it should go in tomcat\webapps\php\ folder

If you are getting  Error “Could not start FCGI server: java.io.IOException: PHP not found. Please install php-cgi” then MSVCR110.dll is missing from your system. Please install  Visual C++ library from Microsoft website “http://www.microsoft.com/en-us/download/confirmation.aspx?id=30679”. Make sure you download and install the x86 version not 64bit version