Is it possible to run a PHP app using tomcat?
Before you tell me to just use httpd, I already have a Java application running on my webserver at host/myapp
. Now I want to install RoundCube at host/roundcube.
One is PHP and one is Java. I keep seeing offhand references saying this is possible but no real instructions. I do not want to put them on separate ports, I need the standard HTTP and HTTPS ports.
Does anyone have any resources for this?
Yes it is Possible Will Den. we can run PHP code in tomcat server using it's own port number localhost:8080
here I'm writing some step which is so much useful for you.
How to install or run PHP on Tomcat 6 in windows
download and unzip PHP 5 to a directory,
c:\php-5.2.6-Win32
- php-5.2.9-2-Win32.zip Downloaddownload PECL 5.2.5 Win32 binaries - PECL 5.2.5 Win32 Download
rename
php.ini-dist
tophp.ini
inc:\php-5.2.6-Win32
Uncomment or add the line (remove semi-colon at the beginning) in
php.ini
:;extension=php_java.dll
copy
php5servlet.dll
from PECL 5.2.5 toc:\php-5.2.6-Win32
copy
php_java.dll
from PECL 5.2.5 toc:\php-5.2.6-Win32\ext
copy
php_java.jar
from PECL 5.2.5 totomcat\lib
create a directory named
"php"
(or what ever u like) intomcat\webapps
directorycopy
phpsrvlt.jar
from PECL 5.2.5 totomcat\webapps\php\WEB-INF\lib
Unjar or unzip
phpsrvlt.jar
for unzip use winrar or winzip for unjar use :jar xfv phpsrvlt.jar
change both
net\php\reflect.properties
andnet\php\servlet.properties
tolibrary=php5servlet
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
create
web.xml
intomcat\webapps\php\WEB-INF
with this content: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 Computercreate
test.php
for testing undertomcat\webapps\php
likeRestart tomcat
browse
localhost:8080/php/test.php
If anyone's still looking - Quercus has a war that allows to run PHP scripts in apache tomcat or glassfish. For a step by step guide look at this article
There this PHP/Java bridge. This is basically running PHP via FastCGI. I have not used it myself.
Caucho Quercus can run PHP code on the jvm.
php-servlet.jar
andJavaBridge.jar
webapp/WEB-INF/lib
folder of your projectok
You may have other content inside this file, just make sure you have added everything between the web-app tag.
You can do other special things with this as well. You cal learn more about it here: http://php-java-bridge.sourceforge.net/pjb/how_it_works.php
A tad late, but here goes.
How about http://wiki.apache.org/tomcat/UsingPhp if you just want to run the real php on tomcat.
Concerning running tomcat on port 80 there's always jsvc, just google jsvc + tomcat.