Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Our current stack is Apache + Tomcat + MySQL, using ProxyPass AJP to fire requests from Apache to Tomcat. We also run PHP for Wordpress on the same sites, and so need working .htaccess files. In response to an annoying problem (see this Stack Overflow page), we're considering alternative stacks. Note that we generally quite like apache, but this problem is a show-stopper: if we can't fix it, we can't use Apache.

Alternatives include:

  • Tomcat alone
  • Glassfish (Java app server, forked from Tomcat)
  • Jetty (Java server)
  • Resin
  • LightTPD (lightweight HTTP server)
  • Nginx (lightweight HTTP server)

The way I see it, solutions fall into two camps: the pure Java camp, such as Glassfish; or the split camp such as our current Apache + Tomcat. We like the idea of a pure Java solution, since fewer moving parts should mean less to go wrong; but do any of them support PHP, .htaccess files, etc?

In theory we could do the split the other way - have a simple front end that proxies to Apache on only those bits that need those features - but in practice that would be 80% of requests.

What options do people suggest?

share

locked by HopelessN00b Dec 5 at 3:53

This question exists because it has historical significance, but it is not considered a good, on-topic question for this site, so please do not use it as evidence that you can ask similar questions here. This question and its answers are frozen and cannot be changed. More info: help center.

    
Would you mind elaborating your "annoying show-stopper problem" a bit more, or is it completely irrelevant? –  mark Apr 30 '09 at 14:27
    
Follow the link to the StackOverflow page for more details. It's a bug where clients are delivered the wrong response - sometimes getting JS or CSS files instead of HTML ones, or just the wrong page entirely. We've tried pretty much everything within Apache and Tomcat we can think of. –  Marcus Downing Apr 30 '09 at 15:57

5 Answers 5

up vote 7 down vote accepted

I strongly suspect your problem is related to AJP.

I was in a course with one of the main Tomcat developers a few weeks ago (he was running it), his advice was to avoid AJP and mod-JK etc, and stick to regular mod-proxy HTTP.

Reasons:

  1. It's by far the most mature and stable Tomcat connector.
  2. Neither AJP implementation has been consistently developed; both projects have suffered a bit of stop / start.
  3. NBIO does not result in any real world performance gain over blocking-IO, in this situation.

My advice, try using regular mod-proxy HTTP with your current setup. It's the least change for you and it will take you on to the most widely used and stable Tomcat deployment architecture.

/ Richy

share
    
I suppose I could give it a go. Do you have any hard numbers on the performance difference? –  Marcus Downing May 27 '09 at 12:58
    
How can I use regular mod-proxy and still get the correct host names coming through to Tomcat? I'm pretty sure they're all being recieved as localhost at the moment. –  Marcus Downing Jun 5 '09 at 15:06
2  
ProxyPreserveHost On is probably what you're looking for. httpd.apache.org/docs/2.2/mod/mod_proxy.html#proxypreservehost –  Stephen Veiss Jun 17 '09 at 1:06

My current preferred stack is to use nginx as a replacement for Apache. Wherever necessary, php-fpm fills in the need for PHP. Such a setup has worked nicely for deploying apps such as Rails, Magento and SugarCRM.

share

Glassfish will be more scalable than Tomcat because it uses Grizzly (NIO based). You don't have many options other than a variation of Tomcat, Jetty, or Glassfish because of the Java requirement. PHP can be run using Quercus, but it may be better to just deploy it using Nginx.

share

There are PHP implementations on Java, The one I know (but haven't used) is this one. There is a blog post on how to install it on GlassFish (including WordPress), but I guess the installation on tomcat is the same. Regarding the .htaccess, you haven't written what exactly you have there, but if it is for URL rerwriting then there is the UrlRewriteFilter who does the same work with the same semantics.

share
    
The .htaccess files are mostly those generated by WordPress, so they contain a few simple RewriteRules –  Marcus Downing Apr 30 '09 at 15:54
    
I guess the PHP will not support them, but it shouldn't be hard to have a process that reads them and passes the definitions to the filter. –  David Rabinowitz Apr 30 '09 at 20:54

Cherokee ? where is he ? http://www.cherokee-project.com/

share
    
While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. –  pauska Sep 4 '12 at 11:34

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