Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
why not nginx proxy(terminate ssl here) to apache and tomcat? this allows you to scale, when needed. – Dmitry V. Jan 28 '15 at 19:26
up vote 2 down vote accepted

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.

share|improve this answer

Option 3 (a somewhat esoteric option) is to run Quercus which provides a PHP implementation in Java. Depends upon your PHP application I guess whether this is viable.


share|improve this answer
The php application will be Wordpress – valmar May 26 '11 at 17:24
Looks like it's been done. Not sure what the current situation is though... YMMV – HTTP500 May 27 '11 at 21:17

Option 1 is fairly simple and flexible, specially in Linux. In addition you can also connect Apache to Tomcat via mod_proxy (as an alternative to mod_jk). I've been using this setup (with ssl, and several virtual sites) for a while, works nice.

share|improve this answer
Do you use only one SSL certificate? If yes, did you create it using openssl or keytool? And did you install it on apache or tomcat? – valmar May 26 '11 at 17:26
I have two certificates (and two IP), installed in Apache, created with openssl, signed by Thawte/Godaddy – leonbloy May 26 '11 at 17:30

I think option 1 is more efficient overall, especially for the PHP side?

I vote for 1. Also there must be a way to use one certificate.

share|improve this answer
Could it be enough to install the certificate on the apache server and tell it to secure all data, which would be tunneled to tomcat, through ssl? – valmar May 26 '11 at 17:28
That sounds right. For two servers it should be ok, but gets more riskier if using same cert for more servers. Also maybe seen already:… – Hax May 27 '11 at 14:08

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.