What it solves: Lo que resuelve:

  1. Using php 5.x on Tomcat 4.x or 5.x Utilizando php 5.x en Tomcat 4.x o 5.x
  2. Enabling php only in one web application, instead of globally. Al habilitar php sólo en una aplicación web, en lugar de a nivel mundial.


The simplest possible configuration is described. La forma más sencilla posible configuración se describe. The descriptions are terse assuming your intelligence. Las descripciones son lacónico asumir su inteligencia.

We will assume php will be installed in c:\ drive. Se asume que php se instalará en la unidad C: \. Substitute with drive letter of your choice. Suplente con letra de la unidad de su elección.

Instructions Instrucciones

  1. Download latest php 5.x zip file. Descargar última php 5.x archivo zip.
    I used He utilizado http://www.php.net/get/php-5.0.2-Win32.zip/from/a/mirror .
  2. Download latest Collection of PECL modules. Descargar última colección de módulos PECL. I used He utilizado 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 Descomprima el archivo zip en cualquier lugar, normalmente c: \ php
  4. Copy php.ini-dist, in c:\php , as php.ini Copiar php.ini-dist, en c: \ php, como php.ini
  5. Uncomment the line (remove semi-colon at the beginning) in php.ini: Descomente la línea (quitar y coma al principio) en php.ini:
    ;extension=php_java.dll ; extensión = php_java.dll
  6. Extract php5servlet.dll from pecl zip file to c:\php (Uncheck "Use Folder Names" in WinZip). Extracto de php5servlet.dll PECL zip en c: \ php (la opción "Usar nombres de carpetas" en WinZip).
    Ensure that the file is actually present in c:\php Asegúrese de que el archivo está realmente presente en c: \ php
  7. Install Tomcat and create a directory under webapps. Instalar Tomcat y cree un directorio en webapps. Lets say it is named fun . Digamos que se llama diversión.
  8. Create WEB-INF directory under fun Crear WEB-INF directorio bajo la diversión
  9. Create lib directory under WEB-INF Crear directorio lib bajo WEB-INF
  10. Create web.xml under WEB-INF with the following contents: Crear web.xml bajo WEB-INF con el siguiente contenido:
     php PHP  net.php.servlet  php-formatter PHP-formateador  net.php.formatter  php PHP  *.php *. PHP  php-formatter PHP-formateador  *.phps *. PHP 
  11. Extract php5srvlt.jar and extract/unjar (jar xvf …) it under c:\ Extracto extracto php5srvlt.jar y / unjar (jar xvf…) bajo c: \
  12. Modify both the files reflect.properties and servlet.properties to change the line library=phpsrvlt to library=php5servlet and save them. Modificar los archivos y reflect.properties servlet.properties para cambiar de línea en la biblioteca = phpsrvlt a la biblioteca = php5servlet y salvarlos. This indicates the file name of the dll file which is loaded by the Java application to serve the requests. Esto indica el nombre de archivo del archivo DLL que se carga por la aplicación Java para servir a las solicitudes. In my version the name of the dll was php5servlet.dll . En mi versión el nombre de la dll se php5servlet.dll. Your mileage may vary. Su experiencia puede ser diferente. This has no connection with the name of the jar file which can be anything. Esto no tiene relación alguna con el nombre del archivo jar que puede ser cualquier cosa.
  13. Re-create the jar file Re-crear el archivo jar
  14. Copy the jar file to WEB-INF\lib directory created earlier Copie el archivo jar a WEB-INF \ lib directorio creado anteriormente
  15. Add c:\php to your System or User Path in Windows enironment (Hint: Right-click and select Properties from My Computer ) Añadir c: \ php a su sistema o del usuario en Windows Sendero enironment (Pista: clic con el botón derecho y seleccione Propiedades de Mi PC)
  16. Create a file test.php under fun with the following code: Crear un archivo test.php con arreglo a la diversión con el siguiente código:

  17. Start Tomcat (Go to [Tomcat installation directory]\bin and type Tomcat). Inicio de Tomcat (Ir al [directorio de instalación de Tomcat] \ bin y el tipo Tomcat).
  18. Open your browser and go to http://localhost:8080/fun/test.php Abra su navegador y vaya a http://localhost:8080/fun/test.php
  19. Ensure that there are no errors displayed. Asegúrese de que no hay errores mostrados. Instead you get an informative screen with php version information and whole lot of details En cambio se obtiene una pantalla informativa con información sobre la versión php y gran cantidad de detalles

Let me know if this document is helpful to you. Quiero saber si este documento es útil para usted.

Update: Made minor revision to highlight some key elements. Actualización: Made revisión menor para destacar algunos elementos clave.

Solutions to common problems by users: Soluciones a los problemas comunes de los usuarios:
Whoever is getting this error “java.lang.UnsatisfiedLinkError: no php5servlet in java.library.path”. Quien está recibiendo este error "java.lang.UnsatisfiedLinkError: no php5servlet en java.library.path". Please check the two properties file, whether there are any blank spaces. Por favor, comprueba las dos propiedades de archivo, si hay espacios en blanco. I was stuck in this problem for 2 days. Yo estaba atascado en este problema durante 2 días. There should be only one line, and no blank spaces. Debe haber sólo una línea, y no espacios en blanco. Check it now!!!. Comprobar ahora!. This is where the problem is lying. Aquí es donde el problema está mintiendo.
–Arundhati - Arundhati

The versions of php and pecl must be the same. Las versiones de PHP y PECL debe ser la misma.
–Mirek Mocek - Mirek Mocek

You might want to add a reboot step at the end of your instructions. Es posible que desee añadir un paso de reiniciar al final de sus instrucciones. It would eliminate a lot of the problems with the unsatisfied link errors. Se eliminaría una gran cantidad de los problemas con el enlace insatisfechas errores.
– Chuck Rosendahl -- Chuck Rosendahl

Note: Nota:
If you find this tutorial useful, please consider donating and enjoy the pleasure of giving. Si encuentra útil este tutorial, por favor considere donar y disfrutar del placer de dar.