What it solves:它解决了:

  1. Using php 5.x on Tomcat 4.x or 5.x使用PHP 5.x的关于Tomcat和4.x或5.x的
  2. Enabling php only in one web application, instead of globally.使PHP的,只有在一个Web应用程序,而不是全球。


The simplest possible configuration is described.最简单的配置可能是所描述的。 The descriptions are terse assuming your intelligence.说明是简洁假设您的情报。

We will assume php will be installed in c:\ drive.我们将假定的PHP将被安装在C : \驱动器。 Substitute with drive letter of your choice.以驱动器的信您的选择。

Instructions 指示

  1. Download latest php 5.x zip file.下载最新的PHP 5.x的zip档案。
    I used我用 http://www.php.net/get/php-5.0.2-Win32.zip/from/a/mirror http://www.php.net/get/php-5.0.2-win32.zip/from/a/mirror .
  2. Download latest Collection of PECL modules.下载最新收集的PECL模块。 I used我用 http://www.php.net/get/pecl-5.0.2-Win32.zip/from/a/mirror 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解压缩的PHP 5.x的zip档案的任何地方,通常是将C : \ php
  4. Copy php.ini-dist, in c:\php , as php.ini复制包中将php.ini - dist ,在C : \ PHP中 ,作为在php.ini
  5. Uncomment the line (remove semi-colon at the beginning) in php.ini:注释线(移除半结肠在开始时)在php.ini :
    ;extension=php_java.dll ;扩展= php_java.dll
  6. Extract php5servlet.dll from pecl zip file to c:\php (Uncheck "Use Folder Names" in WinZip).提取php5servlet.dll的PECL zip档案到C : \的PHP (取消勾选“使用文件夹名称”在WinZip的) 。
    Ensure that the file is actually present in c:\php确保该文件其实是目前在C : \的PHP
  7. Install Tomcat and create a directory under webapps.安装的Tomcat和创建一个目录下的webapps 。 Lets say it is named fun .可以说这是命名为乐趣
  8. Create WEB-INF directory under fun创建Web - INF目录下的乐趣
  9. Create lib directory under WEB-INF创建目录下的Web -干扰素
  10. Create web.xml under WEB-INF with the following contents:创建web.xml下的Web -干扰素具有下列内容:
     php PHP的  net.php.servlet  php-formatter PHP的-格式化  net.php.formatter  php PHP的  *.php *.的PHP  php-formatter PHP的-格式化  *.phps *. phps 
  11. Extract php5srvlt.jar and extract/unjar (jar xvf …) it under c:\ php5srvlt.jar提取物和提取物/ unjar (罐xvf … … ) ,它在C : \
  12. Modify both the files reflect.properties and servlet.properties to change the line library=phpsrvlt to library=php5servlet and save them.修改这两个文件reflect.properties和servlet.properties改变路线图书馆= phpsrvlt图书馆= php5servlet ,并将它们保存。 This indicates the file name of the dll file which is loaded by the Java application to serve the requests.这表明,档案名称的DLL文件,该文件是加载Java应用服务的要求。 In my version the name of the dll was php5servlet.dll .在我的版本DLL的名称是php5servlet.dll Your mileage may vary.您的里程数可能会有所不同。 This has no connection with the name of the jar file which can be anything.这已没有联系的名称,该JAR文件可以任何事情。
  13. Re-create the jar file重新创建JAR文件
  14. Copy the jar file to WEB-INF\lib directory created earlier复制jar文件到Web -干扰素\库目录先前创建的
  15. Add c:\php to your System or User Path in Windows enironment (Hint: Right-click and select Properties from My Computer )添加将C : \ php到您的系统或用户的路径在Windows enironment (提示:点击右键并选择属性从我的电脑
  16. Create a file test.php under fun with the following code:创建一个文件test.php下的乐趣与以下代码:

  17. Start Tomcat (Go to [Tomcat installation directory]\bin and type Tomcat).开始的Tomcat (去[的Tomcat安装目录] \斌和类型的Tomcat ) 。
  18. Open your browser and go to http://localhost:8080/fun/test.php打开浏览器并转到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不是你得到一个翔实的屏幕上用PHP的版本信息和整个很多细节

Let me know if this document is helpful to you.让我知道,如果这份文件是帮助你。

Update: Made minor revision to highlight some key elements.更新:作出轻微修订,以突出的一些关键要素。

Solutions to common problems by users: 解决共同问题的办法,由用户:
Whoever is getting this error “java.lang.UnsatisfiedLinkError: no php5servlet in java.library.path”.无论是谁得到这个错误“ java.lang.unsatisfiedlinkerror :没有php5servlet在java.library.path ” 。 Please check the two properties file, whether there are any blank spaces.请检查两个属性的文件,是否有任何空白。 I was stuck in this problem for 2 days.我是停留在这个问题,为2天。 There should be only one line, and no blank spaces.应该只有一个路线,没有空白。 Check it now!!!.检查它现在! 。 This is where the problem is lying.这是问题所在,是在说谎。
–Arundhati - Arundhati -使Arundhati

The versions of php and pecl must be the same.该版本的PHP和的PECL必须相同。
–Mirek Mocek - mirek mocek

You might want to add a reboot step at the end of your instructions.您可能想要添加一个步骤,重新启动在年底您的指示。 It would eliminate a lot of the problems with the unsatisfied link errors.它会消除了很多的问题与不满链接错误。
– Chuck Rosendahl -夹头r osendahl

Note: 注意:
If you find this tutorial useful, please consider donating and enjoy the pleasure of giving.如果您发现本教程有用,请考虑捐赠和享受的乐趣,让。