11

Nginx is said to be much more resource-efficient and easier to configure than Apache. A friend told me that "it can't do some things that Apache can do, but I don't need those things anyway."

Still, I'm curious: what kinds of things can Apache do that Nginx can't? I don't need an exhaustive list, just a general idea of scenarios where Apache would be a better choice.

4 Answers 4

9

I think the biggest pieces still missing from Nginx is full WebDAV support. Pretty much every other aspect is covered by either the core or a 3rd party module.

Nginx does not support things like mod_php by design, so I'm not sure you can say that Nginx is missing these parts. It's more like Nginx is telling you rather forcefully that using this is stupid.

4
  • +1 While I disagree that every possibly use of mod_php and things like it are "stupid", I do agree with the rest.
    – Chris S
    Apr 12, 2011 at 23:09
  • Is this a php-hater comment or is there something really inherently bad about mod_php? Link? I ask because nearly everything I have uses mod_php.. and please, I don't care what you think is better, I would just like to know what's wrong with mod_php
    – Safado
    Mar 19, 2012 at 18:58
  • 3
    mod_php has nothing to do with PHP itself. It has to do with how PHP interacts with Apache. The problem is that when you embed PHP within Apache then the process that handles PHP and the process that handles a 2kb image file is the exact same process. If the end client is slow then your very expensive process can be serving a small image for 2 seconds, which is time it cannot spend on PHP. Mar 20, 2012 at 0:24
  • +1 "It's more like Nginx is telling you rather forcefully that using this is stupid."
    – user101340
    Apr 25, 2015 at 3:14
4

Apache has a great amount of modules available which allow for some deployment scenarios which are not possible with Nginx.

One example is mod_dav_svn for hosting Subversion over HTTP. It is only available for Apache. Other notable examples are things like mod_perl or mod_php. While most traditional setups can also be done via FCGI (or WSGI, or passenger), having an actual interpreter in-process can be beneficial if you need to e.g. implement custom authentication schemes inside the webserver (like it's done for git or svn hosting with Redmine/ChiliProject).

Generally, your friend is right: most common deployment scenarios can also be solved with nginx, but Apache still is more flexible if you have to build some more "special" stuff.

3

The short version of the story is that Apache has a lot of plugins and community built up around it. Nginx, has only been around for a short time comparatively, and so it doesn't have the community code base yet.

When people ask me what the difference is, Nginx is a steak knife, it's good for a variety of uses and does some things extremely well. Apache is a Swiss Army Knife, it's got a ton of different features and does all of them reasonably well.

3
  • I think you might be slightly outdated on what Nginx can do, in some areas it's far more versatile than Apache. Short of HTTP/1.1 proxying and WebDAV I can't think of many things it's missing. Apr 12, 2011 at 22:10
  • @MartinFjordvald There's quite a few functions Nginx purposely chose not to do, you can't say they're "missing", but you can't claim that Nginx can do everything Apache can either. It's a tradeoff and I applaud Nginx for the choices they've made.
    – Chris S
    Jan 17, 2012 at 23:39
  • Well since my original comment HTTP/1.1 proxying is now supported so we're down to webdav and svn hosting not being supported. That is if we don't consider issues like dynamically linked modules, which is true that nginx has decided not to do so far. Jan 18, 2012 at 7:15
1

Many modules and a ginourmous installed base, for start. But it's not exactly what Apache has that you should be looking at, is what Apache does: it works way better to serve dynamic content like PHP, Python, Perl, Java, etc.

Of course you can do that with Nginx too (but it's a little hackish IMHO), but the solutions are way more proven and mature running on Apache than on NginX, that on its turn is way better than Apache on serving high loads and a superb rewriter/reverse proxy.

For each job, the right tool!

1
  • Maybe this was true prior to 2008 when I first deployed nginx on a production web server, but it doesn't seem so now. I'd love to see an expansion of why you believe Apache's model of including the interpreters in the web server is better. Sep 4, 2012 at 0:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .