What it solves: Che cosa ne risolva:

  1. Using php 5.x on Tomcat 4.x or 5.x Utilizzo di PHP 5.x su Tomcat 4.xo 5.x
  2. Enabling php only in one web application, instead of globally. Php che consente solo in una applicazione web, invece di livello mondiale.


The simplest possible configuration is described. Il più semplice possibile configurazione è descritto. The descriptions are terse assuming your intelligence. Le descrizioni sono terse assumendo la tua intelligenza.

We will assume php will be installed in c:\ drive. Si assume php verrà installato in C: \. Substitute with drive letter of your choice. Sostituirlo con lettera di unità di vostra scelta.

Instructions Istruzioni

  1. Download latest php 5.x zip file. Download ultime php 5.x file zip.
    I used Ho usato http://www.php.net/get/php-5.0.2-Win32.zip/from/a/mirror .
  2. Download latest Collection of PECL modules. Scaricare ultima raccolta di moduli PECL. I used Ho usato 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 decomprimere file zip ovunque, normalmente c: \ php
  4. Copy php.ini-dist, in c:\php , as php.ini Copia php.ini-dist, in c: \ php, come php.ini
  5. Uncomment the line (remove semi-colon at the beginning) in php.ini: Decommentare la riga (rimuovere punto e virgola all'inizio) in php.ini:
    ;extension=php_java.dll ; extension = php_java.dll
  6. Extract php5servlet.dll from pecl zip file to c:\php (Uncheck "Use Folder Names" in WinZip). Estratto da php5servlet.dll pecl file zip in c: \ php (Deseleziona "Utilizza nomi delle cartelle" in WinZip).
    Ensure that the file is actually present in c:\php Garantire che il file è effettivamente presente in c: \ php
  7. Install Tomcat and create a directory under webapps. Installare Tomcat e creare una directory in webapps. Lets say it is named fun . Diciamo che è chiamato il divertimento.
  8. Create WEB-INF directory under fun Creare WEB-INF directory sotto divertimento
  9. Create lib directory under WEB-INF Creare lib directory sotto WEB-INF
  10. Create web.xml under WEB-INF with the following contents: Creare web.xml sotto WEB-INF con il seguente contenuto:
     php PHP  net.php.servlet  php-formatter PHP-formattatore  net.php.formatter  php PHP  *.php *. php  php-formatter PHP-formattatore  *.phps *. php's 
  11. Extract php5srvlt.jar and extract/unjar (jar xvf …) it under c:\ Estratto php5srvlt.jar ed estratto / unjar (jar xvf…) sotto c: \
  12. Modify both the files reflect.properties and servlet.properties to change the line library=phpsrvlt to library=php5servlet and save them. Modificare sia i file reflect.properties e servlet.properties a modificare la riga = phpsrvlt biblioteca a biblioteca = php5servlet e salvarli. This indicates the file name of the dll file which is loaded by the Java application to serve the requests. Questo indica il nome del file del file dll che viene caricato dalla applicazione Java per servire le richieste. In my version the name of the dll was php5servlet.dll . Nella mia versione il nome della dll è stato php5servlet.dll. Your mileage may vary. Il tuo distanza in miglia può variare. This has no connection with the name of the jar file which can be anything. Questo non ha alcun legame con il nome del file jar che può essere nulla.
  13. Re-create the jar file Ricreare il file jar
  14. Copy the jar file to WEB-INF\lib directory created earlier Copiare il file jar WEB-INF \ lib directory creata in precedenza
  15. Add c:\php to your System or User Path in Windows enironment (Hint: Right-click and select Properties from My Computer ) Aggiungere c: \ php il sistema o il percorso utente in Windows enironment (Suggerimento: Fai clic destro e selezionare Proprietà dal computer)
  16. Create a file test.php under fun with the following code: Creare un file test.php sotto divertimento con il seguente codice:

  17. Start Tomcat (Go to [Tomcat installation directory]\bin and type Tomcat). Inizio Tomcat (Vai alla [directory di installazione di Tomcat] \ bin e il tipo di Tomcat).
  18. Open your browser and go to http://localhost:8080/fun/test.php Apri il browser e passare al http://localhost:8080/fun/test.php
  19. Ensure that there are no errors displayed. Garantire che non vi siano errori visualizzati. Instead you get an informative screen with php version information and whole lot of details Invece, si ottiene un informativo schermo con versione di PHP informazioni e tutta la partita di dettagli

Let me know if this document is helpful to you. Fammi sapere se questo documento è utile a voi.

Update: Made minor revision to highlight some key elements. Aggiornamento: Made revisione minore per evidenziare alcuni elementi chiave.

Solutions to common problems by users: Soluzioni a problemi comuni da parte degli utenti:
Whoever is getting this error “java.lang.UnsatisfiedLinkError: no php5servlet in java.library.path”. Chi si sta l'errore "java.lang.UnsatisfiedLinkError: nessun php5servlet in java.library.path". Please check the two properties file, whether there are any blank spaces. Si prega di consultare le due file di proprietà, se vi siano spazi vuoti. I was stuck in this problem for 2 days. Mi è stato bloccato in questo problema per 2 giorni. There should be only one line, and no blank spaces. Ci dovrebbe essere una sola riga, e non gli spazi vuoti. Check it now!!!. Check it!!!. This is where the problem is lying. È qui che il problema sia di mentire.
–Arundhati - Arundhati

The versions of php and pecl must be the same. Le versioni di PHP e pecl deve essere la stessa.
–Mirek Mocek - Mirek Mocek

You might want to add a reboot step at the end of your instructions. Si può aggiungere un riavvio passo alla fine del vostro istruzioni. It would eliminate a lot of the problems with the unsatisfied link errors. Si eliminerebbe un sacco di problemi con il collegamento insoddisfatta errori.
– Chuck Rosendahl -- Chuck Rosendahl

Note: Nota:
If you find this tutorial useful, please consider donating and enjoy the pleasure of giving. Se si trova questo tutorial utile, ti invitiamo a prendere in considerazione la donazione e godersi il piacere di dare.