Today’s IT and DevOps teams have not one, but two, feature-rich open source Web servers to choose from: NGINX and Apache HTTP Server (which is often called simply “Apache”). At a high level, both platforms do the same core thing: Host and serve Web content. Both also offer comparable levels of performance and security.
Yet when you dive into the details, you’ll find that there are many differences between NGINX and Apache. Each platform takes its own approach to configuration management, performance optimization, and more. Understanding these differences is essential for making the right choice when deciding between NGINX and Apache as a Web hosting solution.
What is Apache?
Apache is a Web server released under the open source Apache 2.0 license. Like all Web servers, it hosts Web content – such as HTML pages, PHP files, and audio and video – and serves the content to users when they visit a website. It can host content for websites on the public Internet, or for internal company websites on an Intranet.
As noted above, the full name of the Apache Web server is Apache HTTP Server. (Sometimes, the name is stylized as Apache HTTPd Server, although technically speaking HTTPd – short for HTTP daemon – is only one component of the server.) But most people call it simply “Apache” colloquially. This practice can be a bit confusing because “Apache” can also refer to the Apache Software Foundation, a non-profit organization that oversees dozens of open source projects, of which the Apache HTTP Server is just one (although it also happens to be the oldest and – arguably – most important Apache Software Foundation project).
Thus, you might hear someone say, “Apache develops Hadoop,” because Hadoop (an open source big data platform) is another project overseen by the Apache Software Foundation. Or, people will talk about “Apache Spark,” another big data tool whose development is overseen by the Apache Software Foundation. But that does not mean that Apache the Web server is responsible for creating Hadoop or Spark; the relationship between the projects is simply that they are governed by the same non-profit organization and share the same software license, the Apache license. (Specifically, most Apache projects use the Apache 2.0 license, which dates to 2004.)
Benefits of Apache
Since its early days, Apache has offered a variety of benefits that have made it a popular Web server solution for many IT and DevOps teams.
One advantage, at least in the eyes of many IT professionals, is that Apache is open source. Its open source model not only makes it free of cost, but also allows community developers to extend and modify it easily. While NGINX is also open source, some other popular Web servers, like Microsoft IIS, are not.
Apache also offers a modular plugin system that makes it easy to add functionality to an Apache installation by installing modules that enable Apache to serve different types of Web content, log information, compress data, and so on. Modules in Apache can be easily activated and deactivated, providing a flexible solution for extending and controlling how Apache behaves.
In addition to hosting websites on a server, Apache offers the advantage of being able to be configured to run locally on a PC or laptop. This allows Web developers to test websites directly on their workstations, which typically enables faster performance (because data does not have to travel over a network) and simpler testing configurations.
Finally, although Apache was closely tied to Linux (which is how the “LAMP stack,” short for Linux-Apache-MySQL-PHP, became popular) historically, modern versions of Apache can run on virtually every type of operating system — Windows, Linux, macOS, and even Android. In addition, Apache configurations can typically be easily migrated from one type of operating system platform to another without requiring significant modifications. These features make Apache a highly cross-platform Web server solution.
What is NGINX?
NGINX is a Web server that is designed to also work as a reverse proxy server, a load balancer, and an HTTP cache. NGINX is open source and governed by a BSD license.
While Apache can be configured to perform these various additional tasks, it was designed first and foremost as simply a Web server.
Sysoev released NGINX to the public in 2004. At first, the server made a relatively small splash; until circa 2010, few IT teams were considering NGINX as a serious alternative to Apache. But as the Web continued to grow, NGINX gained more and more prominence as a Web server that promised to surpass Apache in performance when handling large numbers of concurrent connections. Around 2016, NGINX finalled surpassed Apache in overall popularity and became the most widely used Web server in the world. It retains that distinction today.
A company associated with the NGINX project, called NGINX, Inc., was founded in 2011, and was later bought by F5 Networks in 2019. It sells support services for NGINX, as well as add-on components. The core NGINX software is free to download and use, but, as noted below, an alternative commercial version of NGINX (which costs money) provides additional features.
Benefits of NGINX
NGINX offers many of the same benefits as Apache. It’s open source and (in its core open source form, at least) freely available to use.
Unlike Apache, however, NGINX has a somewhat simpler configuration system. Some of the functionality that would have to be added to an Apache installation using modules is included in NGINX by default, which means that there is less setup for admins to perform. For example, NGINX caches Web content by default in order to enable faster performance when multiple users request the same content.
The tradeoff for NGINX’s simpler configuration is that it is more difficult to add functionality to NGINX once it is installed. This is because NGINX does not offer as many modules as Apache. In addition, functionality that could be added to Apache after installation using a module must be included in NGINX at the time that NGINX is compiled in many cases. This makes it more difficult to turn functionality on and off in NGINX, because doing so would require NGINX to be recompiled – a process that takes time and requires software tools that are not typically installed on servers by default.
NGINX also has a smaller overall resource footprint than Apache or other popular Web servers in most cases. It takes up less storage space and consumes less memory. For these reasons, NGINX can help to save money because it can run well on servers that are less powerful than those that host Apache. This advantage is particularly important if NGINX runs in the cloud, in which case IT teams can choose less expensive virtual machine instances to host it. (It’s worth noting that both NGINX and Apache can be installed and run even on cheap PCs, it’s not as if either Web server requires truly high-end hardware. However, NGINX tends to do a better job than Apache of maintaining strong performance when faced with large volumes of connections even if it is running on less expensive hardware, due to its lower resource consumption.)