views:

2345

answers:

6

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 however and one is java. I keep seeing offhand references saying this is possible but no real instructions. No, 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?

+4  A: 

It's quite common to run Tomcat behind Apache. In Apache you can then direct certain URLs to Tomcat, and have Apache/PHP handle the others (including the static images).

(On Unix, Tomcat itself cannot securely made to run on port 80, while Apache can. Tomcat, being a Java process, would be required to run as root, while Apache will switch to non-root privileges as soon as port 80 has been claimed. So, running Apache on port 80 and have it redirect some or all requests to Tomcat, is quite common on Unix.)

Arjan
This is definitely the simplest option. For calling Tomcat from Apache you should have a look at the Apache mod_jk module.
Steve Claridge
Of course you can run tomcat on port 80 on Unix without being root. Just use iptables to redirect port 80 to port 8080.
Kim
@Kim, I'd not classify using iptables as running Tomcat on port 80, but you're right: using Apache is not the only option. (Using Apache does have other benefits though, like serving static content. My statement "is to be preferred" was certainly a bit too simplified.)
Arjan
Nowadays, in Ubuntu 10.04 Tomcat is configured with authbind to use ports under 1024 and works very nicely. Using Quercus you can also run some (most) PHP scripts without a hitch.
Photodeus
+4  A: 

Caucho Quercus can run PHP code on the jvm.

Equistatic
A: 

There this PHP/Java bridge. This is basically running PHP via FastCGI. I have not used it myself.

Will Hartung
A: 

You can bridge the two using mod_jk for apache http. When I receives requests for your servlet, it will just forward them on to tomcat.

A bit dated: http://www.howtoforge.com/apache2_tomcat5_mod_jk_integration

A: 

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.

phil
A: 

tomcat is designed as JSP servlet container. Apache is designed PHP web server. Use apache as web server, responding for PHP request, and direct JSP servlet request to tomcat container. should be better implementation.

lwpro2