leemccarthyn's picture

Why are most of the Turnkey web based appliances based on Apache rather than nginx? (wordpress, owncloud, etc.

Any techical reasons or just old a habit?

Forum: 
Jim Belefort's picture

Use both and prefer nginx, but apache is old school :-)

Jeremy Davis's picture

There are a number of reasons why we choose Apache over Nginx. Some of them are to do with maximising our internal productivity. Some are to do with end users such as yourselves.

It's probably well worth noting right from the start though, that for many appliances (e.g. WordPress) Nginx would be a totally legitimate option (some, such as Jim may even argue preferable).

From our internal perspective, using Apache as the default, reduces maintenance overhead. It means that we can provide a vanilla LAMP appliance, then use that as a base to provide a whole raft of other appliances (e.g. WordPress, ownCloud, etc).

We do also have a Nginx appliance, so arguably could do something similar there. But some PHP software recommends Apache, and/or is not officially supported on Apache. Often that's to do with .htaccess file redirects and/or securing of specific files. Whilst in most (if not all) scenarios where that applies, we could rewrite the .htaccess file contents to an Nginx config file, it does increase the overhead for us, not to mention the risk of oversights and mistakes (they happen anyway from time to time, but I think you'd agree, the less the better).

Another somewhat related factor to our preference for Apache is it's level of flexibility. It has a ton of modules that allows for extended functionality that Nginx doesn't. There are even some scenarios, where Apache is the only server that provides full functionality, e.g. WebDAV in our FIleserver appliance (Nginx only has a partial implementation of WebDav).

Whilst we've watched Nginx become more and more popular over the years, it's worth noting that our benchmarking suggests that given enough resources, Apache performs as well as, if not better than Nginx in many scenarios. Although serving of static content is not one of them; that's where Nginx rules supreme! Before you argue, note the "given enough resources"! In a low resource scenario Nginx will often beat Apache (hands down on static content, and sometimes also with PHP).

Also from a development/maintenance perspective, internally, we're all pretty well familiar with Apache config; Nginx config - not so much. We're not incapable of configuring Nginx, and in reverse proxy scenarios (e.g. GitLab, Mayan-EDMS, etc) we favour Nginx. Personally I find Apache far more intuitive to configure (probably mostly due to familiarity). Plus there's just so much more documentation on Apache.

On the end user side of things, there are a few "user friendliness" aspects that also contribute to our decision. Again I note the documentation, both from Apache themselves, but also in general online.

Another factor is that Webmin (the pre-installed web-based Admin UI all TurnKey apps ship with) only has an Apache config module in it's "core modules". There is a 3rd party Nginx module, but it's not maintained, and we're not really in a position to start maintaining something more right now (Webmin is written in Perl, which is not a language I am familiar nor comfortable with). Providing an unmaintained module to an "always on" internet available service on 70% of our library seems like a really bad idea!

So at this point, it's much easier (and arguably more reliable) to just build all PHP apps on top of our LAMP appliance. FWIW, at some point in the future, we're looking to move to a hybrid container build (still all contained within the ISO/VM/etc), where the components are provided by containers. When we get there, we'll likely change the default (at least for many PHP apps) to Nginx, and users could choose to use Apache instead quite easily if they wished.

Hope that sheds some light! :)

Hedwig A. Brunson's picture

Apache is an open-source HTTP server whereas Nginx is a high-performance asynchronous web server and reverse proxy server. ... In Apache HTTP server, a single thread is associated with only one connection, whereas a single thread in Nginx can handle multiple connections

Jeremy Davis's picture

Both are open source, although Nginx does also have a non-free version.

It's also worth noting that Nginx can only serve static content, or reverse proxy. Whereas Apache can run a number of different languages (e.g. PHP, Perl, Python, etc) directly itself (e.g. it doesn't require additional services running to process the code). It's also really well documented and extremely versatile.

Whilst Nginx (running as a reverse proxy leveraging PHP-FPM or similar) may outperform Apache on lower spec hardware, if you give Apache enough resources, it will beat Nginx, at least serving PHP!

Also FWIW whilst the default mpm prefork model is one client, one connection, if you enable keep-alive, each connection can handle multiple concurrent tcp streams (although only to the one client).

Whilst I definitely see the value of Nginx, I have a really soft spot for Apache and I suspect that it will remain the most popular and common webserver for quite some time (although I note Nginx is slowly making inroads).

Add new comment