8
Posted on 12:35 AM by Badragheh and filed under ,

1.download and unzip PHP 5 to a directory, c:\php-5.2.6-Win32
http://www.php.net/get/php-5.2.9-2-Win32.zip/from/a/mirror

2. download PECL 5.2.5 Win32 binaries.
http://museum.php.net/php5/pecl-5.2.5-Win32.zip

3.rename php.ini-dist to php.ini in c:\php-5.2.6-Win32

4.Uncomment or add the line (remove semi-colon at the beginning) in php.ini:
;extension=php_java.dll

5.copy php5servlet.dll from PECL 5.2.5 to c:\php-5.2.6-Win32

6.copy php_java.dll from PECL 5.2.5 to c:\php-5.2.6-Win32\ext

7.create a directory named "php" (or what ever u like) in tomcat\webapps directory

8.copy phpsrvlt.jar from PECL 5.2.5 to tomcat\webapps\php\WEB-INF\lib

9.unjar or unzip phpsrvlt.jar
for unzip use winrar or winzip
for unjar use : jar xfv phpsrvlt.jar

10.change both net\php\reflect.properties and net\php\servlet.properties to library=php5servlet

11.Recreate the jar file
-> jar cvf php5srvlt.jar net/php/*.*
PS: if the jar file doesnt run you have to add the Path to system variables
for me I added C:\Program Files\Java\jdk1.6.0\bin; to System variables/Path

12.creat web.xml in tomcat\webapps\forphp\WEB-INF with this content:


<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance "

xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd ">

<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>


13.Add PHP path( c:\php-5.2.6-Win32) to your System or User Path in Windows enironment (Hint: Right-click and select Properties from My Computer

14. create test.php for testing under tomcat\webapps\php like

15.Restart tomcat

16.browse http://localhost:8080/php/test.php
8
Responses to ... How to install or run PHP on Tomcat 6 in windows
Bob said... January 14, 2011 12:08 PM

I tried these install steps, several times, but I am getting two errors when I try to browse test.php:

When I first browse I get:

java.lang.UnsatisfiedLinkError: no php5srvlt in java.library.path

If I refresh the page I get:

java.lang.UnsatisfiedLinkError: net.php.servlet.send(Ljava/lang/String;Ljava/lang/String;

The zips I used are:
php-5.3.5-Win32-VC6-x86.zip
pecl-5.2.5-Win32.zip

I am running apache-tomcat-6.0.29 on WinXP SP2.

I have googled for this error, but no solutions I found worked.

I followed the install steps very carefully - did it three times.

Any ideas on how to fix?

Thanks,

--Bob

jlsager said... February 7, 2011 10:47 AM

I just got this working nicely but had to use the same directory name in step #12 that I used in step #7. For example, if you used "tomcat\webapps\php" in step #7, use that same directory (not "tomcat\webapps\forphp") in step #12. Maybe that small point of clarification will help.

Brad said... February 24, 2011 3:57 PM

This worked great as soon as I figured out I needed the 32bit JDK in my Java_Home variable. Thanks for the write up! Now if only there was a 64bit version of the PHP DLL.

Anonymous said... April 9, 2011 10:16 PM

Hi,

I tried to set this up but failed. Tomcat Booted properly, but the moment I tried to access test.php it charshed with a thread dump. It threw the following error.
===================================
EXCEPTION_ACCESS_VIOLATION with the problematic dll being php5ts.dll. Is it due to the 32 bit and 64 bit java difference?

Chet said... June 25, 2011 8:31 AM

Can someone explain the needed differences in directions between this example and my case:

Tomcat v.7.0.14
PHP VC6 32bit Win 5.2.17

Other useful information:
IDE Eclipse helios

The PHP version is so vastly different that almost all of the steps here are nonsensical.
i want to use current versions for sure.

What I really need is a known good install procedure for php that I can test with a known example in eclipse. I installed php and dynamic web projects that target php files dont do anything so it appears to fail.

Help! Please!

nurmawati said... November 28, 2011 12:39 AM

awesome. it works!

harish reddy said... January 8, 2012 2:21 AM

im getting same errors as bob..,
When I first browse I get:

java.lang.UnsatisfiedLinkError: no php5srvlt in java.library.path

If I refresh the page I get:

java.lang.UnsatisfiedLinkError: net.php.servlet.send(Ljava/lang/String;Ljava/lang/String;
pls help

harish reddy said... January 8, 2012 2:57 AM

in tomcat log i found following error...,

SEVERE: StandardWrapper.Throwable
java.lang.UnsatisfiedLinkError: no php5srvlt in java.library.path
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.loadLibrary0(Unknown Source)
at java.lang.System.loadLibrary(Unknown Source)
at net.php.reflect.loadLibrary(reflect.java:34)
at net.php.reflect.(reflect.java:29)
at net.php.servlet.init(servlet.java:157)


pls help me to solve this., what is dat java.library.path how to solve this.,