Forum: 

Apache rather than nginx?

zebios'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?

Référencement web

Jeremy Davis's picture

There are a few reasons why we default to Apache over something else (e.g. Nginx).

Here's a few reasons OTTOMH (some are sort of related):

  • Fully featured - e.g. Nginx does not fully implement WebDAV (as used in our Fileserver appliance).
  • More flexible - Nginx is a fantastic webserver; but it's not as adaptable or as mature as Apache. Nginx is awesome within a range; Apache is a jack of all trades (and probably master of almost none - WebDAV seems to be an exception).
  • More widely supported - almost every webapp available to humankind (particularly php apps) provide support for running on Apache. Most will still run on Nginx, but many are either not officially supported, not well documented, or combo of both.
  • More OOTB plugins (i.e. tons of ready to install Apache modules) - makes development and maintenance easier.
  • More user friendly - Apache config is pretty straight forward in comparison to Nginx
  • Better/more documentation - Apache docs are incredible!
  • Supported Webmin module available - many TurnKey users are Linux newbs, so having a GUI for config is pretty much a necessity. There is a third party Nginx Webmin module, but it's not supported and hasn't been updated in years.

    FWIW, I still think that the massive rise in Nginx usage is at least in part due to the fact that it's "cool", rather than any particularly good technical reason. FYI, despite claims that it is fundamentally better, one of our hosting partners has demonstrated that that's not always the case. Given sufficient resources, in many scenarios, the performance difference between Apache and Nginx is negligible.

    On the flip side, I would argue that under low resource scenarios, and using non-optimized config, Nginx will almost always perform better than Apache. Many users don't have the knowledge or inclination to performance tune Apache. As the tuning needs to take into account the normal load and resource availability of the server, we can't pre-tune it any more than we currently do. So OOTB, end users will almost always notice an improvement been an untuned Apache and an untuned Nginx.

    Also the flipside of being less adaptable and less featureful, is that it's also going to generally have a smaller codebase and therefore less attack vectors and less likelihood of unnoticed security related bugs. So essentially it should be more secure OOTB.

    None of the above Apache "advantages"/Nginx "disadvantages" are complete showstoppers for many (probably most) of the appliances that currently use Apache. And in fact, we are considering moving some appliances to Nginx for our next release (v15.0). WordPress is definitely one that will be on top of that list (if we do go ahead with it).

    If we do go that way, we'll at least adopt the Nginx Webmin module and start maintaining it ourselves. Although we may actually drop Webmin altogether for v15.0. I'm pretty keen on swapping it out for Ajenti but we'll have to see. Ajenti actually has a ton less modules than Webmin, but it's written in Python (our language of choice; Webmin is written in Perl) so developing new modules (that we'd push back to Ajenti so everyone benefits - even non TurnKey Ajenti users...) shouldn't be too big a deal.

    I'd be really interested to hear your thoughts, preferences and rationale for preferring Nginx and any response you may have to the points I have raised.

  • Yuri's picture

    Between these projects there are significant differences that can affect the performance, opportunities and implementation time required to implement and launch each of the solutions. The choice is a series of compromises and do not neglect the tests. Ultimately, there is no one universal web server for all possible tasks, so it is important to find the solution that best suits your goals and objectives. Nginx knows 99% of everything that the modern market needs for productive work.

    Basic tests show the following: Apache + mod_php

    Total transferred: 3470000 bytes

    HTML transferred: 120000 bytes

    Requests per second: 2395.73 [# / sec] (mean)

    Time per request: 4.174 [ms] (mean)

    Time per request: 0.417 [ms] (mean, across all concurrent requests)

    Transfer rate: 811.67 [Kbytes / sec] received

     

    NginX + PHP-FPM Total transferred: 1590000 bytes

    HTML transferred: 120000 bytes

    Requests per second: 5166.39 [# / sec] (mean)

    Time per request: 1.936 [ms] (mean)

    Time per request: 0.194 [ms] (mean, across all concurrent requests)

    Transfer rate: 801.82 [Kbytes / sec] received

    Apache handles 2400 requests per second, compared to 5200 requests that for the same time processes Nginx. (basic test, almost without content)

    If you work with different languages ​​like CSS, JS and images, then NginX is more suitable for you. Its performance will be higher, but PHP will not become faster. It will also be more reliable in terms of protection from DDoS, but CDN is still the best solution.

    According to statistics Netcraft nginx served or proxyed 29.38% of the most loaded sites in September 2017. Here are some examples of successful implementation of nginx: Dropbox, Netflix, Wordpress.com, FastMail.FM

    Perhaps for Western countries it is not so popular yet, but here is the statistics in Russia:

    https://statonline.ru/metrics/web_server_soft?tld=en

    https://www.runfo.ru/statistika-rossijskogo-interneta

    Given that the market share of Wordpress sites is growing daily, and Nginx works well in conjunction with Wordpress.

    Using Webmin in my opinion should not impede the development of projects under Nginx. It is quite possible to use WinSCP + PuTTY.

     

    p.s. sorry, I have bad English)

    Yuri's picture

    By the way, here's a good example for comparison. Two sites on WordPress - a zebios site built on Apache (https://www.omrseo.com/), and mine, made just a week ago using TurnKey-Nginx PHP FastCGI Server Configuration (not completed https://bitstyl.ru/):

                          result

     

    Jeremy Davis's picture

    I think you misunderstand my position. I'm not at all saying that Apache is best in all scenarios. It's clearly not. What I was saying was that IMO it's the best all-rounder across all scenarios.

    The other points on ease of use and great documentation are also big pluses for many TurnKey users. And while Webmin isn't a showstopper, many of our users are not comfortable on the commandline. As part of TurnKey's mission is to make Linux servers more accessible to the masses, we'd really like to provide a webUI where possible.

    As for performance, my personal experience is also consistent with your tests. It was only relatively recently that our partner pulled me up and shared the results of his testing. As I noted:

    [...] despite claims that [Nginx] is fundamentally better, one of our hosting partners has demonstrated that that's not always the case. Given sufficient resources, in many scenarios, the performance difference between Apache and Nginx is negligible.

    I forget where I read it, but I'll see if I can find the info and post it back.

    Regardless, thanks tons for sharing your perspective. As I said, we're already seriously thinking about switching to Nginx for at least a few appliances (including WordPress) for the next release.

    Your input adds weight to that! :)

    Yuri's picture

    Hi, Jeremy!
    I understand your point of view ... I will not say that I share it, but basically I probably agree.
    I want to give only a couple of reasons in favor of an early shift towards Nginx:
    you wrote - "people want the GUI" and immediately - "... more documentation." 
    My experience shows that those who use the GUI do not read the documentation and vice versa)
    Nginx is very well documented, if there is a desire to seek and read it.

    And this is great news that you still focus on TurnKey + Nginx + MySQL + Adminer, this is all im need for a full web site!

    Thank you so much for your efforts in our prosperity!

    Jeremy Davis's picture

    Regarding those who use a GUI and those that read the docs, you are probably right. I'm somewhat speaking from my own experience and possibly extrapolating that beyond the point I should?!

    I came from Windows (with a bit of batch commandline experience, but mostly GUI user). TBH, I actually found the Webmin Apache module a bit confusing. But the Apache docs were awesome and allowed me to get up and running (via commandline) in no time. TBH I found the Nginx docs a bit dense and I must admit that even now, I often need to google when I'm working with Nginx.

    Regardless, I'm keen to see Nginx used more in our appliances.

    As another heads up though, we'll be moving to MariaDB for v15.0 too. In case you haven't come across it before, MariaDB is a fork of MySQL. It started when the original MySQL dev and many of the MySQL dev team jumped ship when Oracle bought out Sun (who own MySQL). Currently MariaDB is a drop in replacement for MySQL. So you shouldn't notice any fundamental difference.

    Yuri's picture

    hi, Jeremy!
    I like MariaDB
    By the way, I wrote a detailed article on how to install the Let's Encrypt certificate on Nginx PHP FastCGI Server Configuration - with Adminer (TurnKey 14.1), can be useful to anyone. You can see it here. Unfortunately, I'm not strong enough to translate into English, but it probably is not required, everything is described step by step.

    Post new comment