Php – What’s a good setup for running Java and PHP applications with SSL on the same server

apache-2.2javaPHPtomcat

I have one Java- and one PHP-application which I both want to run on the same machine (using Tomcat).

As far as I can see, I have two options:

  • Option 1: Do the classic apache-tomcat setup with mod_jk and let apache handle the php requests and forward all requests to the Java application to tomcat.
  • Option 2: Use only tomcat by installing php on it. So, no extra apache server for handling php.

I don't have much experience with this, so I wondered which option would be the wise one, since I cannot foresee which problems might occur.

I, personally, prefer option 2 because I'd then have to manage just one server instead of two.
However, I have a bad feeling about this since most people out there seem to prefer option 1.

Which option should I pick?

Important: I need SSL support available for both (php and java) applications. As far as I know, creating the CSR file for buying a SSL certificate differs between apache and tomcat (openssl vs. keytool). Since I don't want to purchase two certificates, this has to be kept in mind.

Best Answer

If it were me I would do option 1. The Apache->Tomcat scenario is well documented and well tested. It is also recommended for sites with any amount of static content. PHP under Tomcat is a less commonly implemented. I suspect that it isn't as mature or as well documented.