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.如果您發現本教程有用,請考慮捐贈和享受的樂趣,讓。