19
Posted on 12:35 AM by Softminer 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
19
Responses to ... How to install or run PHP on Tomcat 6 in windows
Bob Carpenter said... January 14, 2011 at 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

Anonymous said... February 7, 2011 at 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 at 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 at 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 at 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 at 12:39 AM

awesome. it works!

harish reddy said... January 8, 2012 at 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 at 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.,

Anonymous said... June 6, 2012 at 2:22 AM

Is there a typo mistake in step 10:

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

Do you mean move or rename these two files ? We cannot rename two files in one folder to the same name right ?
I really cant find out the right way to understand this step! Pls help.

Anonymous said... June 6, 2012 at 2:22 AM

Is there a typo mistake in step 10:

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

Do you mean move or rename these two files ? We cannot rename two files in one folder to the same name right ?
I really cant find out the right way to understand this step! Pls help.

Anonymous said... June 6, 2012 at 10:38 PM

Yeah, people who said they can do it successfully, so how they actually do step 10 ?

Softminer said... June 7, 2012 at 1:22 AM

open both files and change the content of file

Anonymous said... June 23, 2012 at 9:33 PM

I had the same unresolved-link problems until I ran DependencyWalker and it showed that the php install I'd used was actually missing two method exports. The fix was to use *exactly* the versions the OP listed in his instructions. In other words, RTFM.

Manish Kumar Gupta said... May 23, 2013 at 1:18 AM

I just got this working nicely but had to use the same directory name in step #12 that I used in step #7

Now issue is that, im getting blank php page but all content is shown is console itself, except , phpinfo page is runnign OK and displayed all things.

Any ideas on how to fix?

Unknown said... July 16, 2013 at 7:08 PM
This comment has been removed by the author.
Anonymous said... July 16, 2013 at 7:09 PM

Hi, I cannot download PHP 5 from the link that provided. So i download php-5.5.0. However, I can't find php.ini-dist in the php-5.5.0. May I know got any tutorial to install or run PHP 5.5 on Tomcat 6?

Anonymous said... August 12, 2013 at 5:34 AM

How to run php with apache tomcat 8 in linux

Prasad said... August 8, 2014 at 4:59 AM

For Tomcat 7, the default dir for php.ini is actually C:\windows. So modified (enabling modules, extensions etc.) php.ini should be copied to C:\windows. Then run phpinfo();. It should work fine even on Tomcat 7 along side PHP 5.x. I had this problem and struggled a lot when I wanted the mysql statements to work.

Unknown said... July 31, 2015 at 9:44 AM

Why installing/running PHP on Tomcat on windows is a battle of epic proportion?! I am running PHP on tomcat on Mac with no problems. From what I've learned is that Apache is a HTTP server (serving HTML type codes) and Tomcat is a java-based server (container); albeit, HTML code on tomcat runs slower.

Having said this, how does windows screw up things that ONLY a specific version of PHP with supporting tools with post-configuration efforts make it work (perhaps)?

Is there a way to integrate the various components in this discussion thread so an install script does it transparently? I don't mind to put in the effort if I understand how these pieces fit together.

Sorry about my rant/rave; I have spent two days and still no go.