Thinking ...

记录所见,所思,所悟...

导航

Running php 5.x on windows using tomcat 4.x or 5.x


From http://blog.taragana.com/index.php/archive/running-php-5x-on-windows-using-tomcat-4x-or-5x/

What it solves:

  1. Using php 5.x on Tomcat 4.x or 5.x
  2. Enabling php only in one web application, instead of globally.


The simplest possible configuration is described. The descriptions are terse assuming your intelligence.

We will assume php will be installed in c:\ drive. Substitute with drive letter of your choice.

Instructions

  1. Download latest php 5.x zip file.
    I used http://www.php.net/get/php-5.0.2-Win32.zip/from/a/mirror .
  2. Download latest Collection of PECL modules. I used http://www.php.net/get/pecl-5.0.2-Win32.zip/from/a/mirror .
  3. Unzip php 5.x zip file anywhere, normally c:\php
  4. Copy php.ini-dist, in c:\php, as php.ini
  5. Uncomment the line (remove semi-colon at the beginning) in php.ini:
    ;extension=php_java.dll
  6. 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
  7. Install Tomcat and create a directory under webapps. Lets say it is named fun.
  8. Create WEB-INF directory under fun
  9. Create lib directory under WEB-INF
  10. Create web.xml under WEB-INF with the following contents:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <!DOCTYPE web-app PUBLIC
      "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
      "http://java.sun.com/dtd/web-app_2_3.dtd">
    <web-app>
    <servlet>
    	<servlet-name>php</servlet-name>
    		<servlet-class>net.php.servlet</servlet-class>
    	</servlet>
    	<servlet>
    		<servlet-name>php-formatter</servlet-name>
    		<servlet-class>net.php.formatter</servlet-class>
    	</servlet>
    	<servlet-mapping>
    		<servlet-name>php</servlet-name>
    		<url-pattern>*.php</url-pattern>
    	</servlet-mapping>
    	
    	<servlet-mapping>
    		<servlet-name>php-formatter</servlet-name>
    		<url-pattern>*.phps</url-pattern>
    	</servlet-mapping>
    </web-app>
    			
  11. Extract php5srvlt.jar and extract/unjar (jar xvf …) it under c:\
  12. Modify both the files 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.
  13. Re-create the jar file
  14. Copy the jar file to WEB-INF\lib directory created earlier
  15. Add c:\php to your System or User Path in Windows enironment (Hint: Right-click and select Properties from My Computer)
  16. Create a file test.php under fun with the following code:

    <?php phpinfo(); ?>

  17. Start Tomcat (Go to [Tomcat installation directory]\bin and type Tomcat).
  18. Open your browser and go to http://localhost:8080/fun/test.php
  19. Ensure that there are no errors displayed. Instead you get an informative screen with php version information and whole lot of details

posted on 2005-09-14 14:00  barry  阅读(825)  评论(0编辑  收藏  举报