How is Nginx different from Apache

Apache vs. Nginx - web server in comparison

Apache vs. Nginx - web server in comparison

Anyone who wants to launch a website needs a web server. The choice usually falls on one of the two market leaders: Apache or Nginx.

The open source web server Apache has been on the market since 1995 and is by far the most widely used web server after w3techs.com. In contrast, according to netcraft.com, Nginx has a market share of 15%. However, around 46 percent of the top 1000 websites run on the Nginx server; the proportion from the Apache server, on the other hand, is 14 percent.

This may mainly be due to the fact that the central configuration of Nginx is better suited for the needs of Web 2.0. Because the software is specially designed for websites that have a lot of data traffic.

What is a web server?

The task of a web server is to deliver the content stored on the server to the clients. This is done by transmission protocols such as HTTP or HTTPS and network protocols such as IP and TCP. Web servers are used both in local networks (intranet) and as a WWW service on the web.

Apache server

Apache is open source, free web server software created by the Apache Software Foundation and made available free of charge to the web community. Most of the time the server is called “WAMPP” on Windows and “XAMPP” on the Mac.

However, it is recommended to only operate the HTTP server with Windows versions from NT. However, it is included as standard in almost all Linux distributions. The first version was created in 1995 and was based on the NCSA HTTPd, the first available web server. The HTTP server also played a key role in the development of the World Wide Web.

It is often used in combination with databases such as MySQL and server-side scripting languages ​​such as PHP, Perl or Python to create living web pages. Dynamic HTML pages are generated from database content using a scripting language such as PHP. In order to fully exploit the advantages of an operating system, version 2.0 of the HTTP server was equipped with a special library, the Apache Portable Runtime.

The Weberver was introduced in 1995 by Robert McCool and further developed in 1999 under the direction of the Apache Software Foundation. As a standard server, it is characterized by extensive compatibility. It is used by many administrators because of its long history, good documentation and extensive support. Compared to the competition, the web server also scores with its modular structure and the resulting large range of functions.

It is the most widely used server. This is also due to the fact that many users start with shared hosting scenarios that rely almost exclusively on Apache due to the distributed management functions of ".htaccess".

Administrators and web developers also usually implement their first projects on inexpensive shared hosting platforms. Since many systems are delivered with the Apache server as standard, this is preinstalled on all major Linux distributions such as Red Hat, CentOS or Ubuntu.

The number of available extensions and modules and the relatively simple configuration, even in mass hosting environments, make it the web server of choice even for beginners.

Nginx server

Nginx is open source software released under the BSD license. Developed by Russian developer Igor Sysoev, the software includes the web server, an email proxy and a reverse proxy. It was originally planned for the Russian search engine Rambler, for which it is still used today.

The Nginx software has a modular structure. With 41.8% it is just in second place among the most popular web servers and better meets the requirements of Web 2.0. The faster delivery of static content through the parallel processing of requests makes the web server particularly interesting for large and resource-intensive projects, for example.

Thanks to its sophisticated caching and its performance advantages, Nginx is suitable for websites with high traffic. There are two versions: An open source version with BSD license and Nginx Plus with support and additional enterprise functions. The web server implements something like a module system. The biggest difference to Apache is the event-based queries. In addition, it has a strong modular structure.

comparison

One of the main disadvantages of Apache is its performance. This is not a big problem for smaller sites, but as the number of simultaneous requests increases, the server's hunger for resources increases steadily. Countless comparison tests prove the speed advantages of Nginx over Apache.

The two web servers essentially differ in how they handle incoming client requests. However, both servers each use their own tactics and ideas to meet the requirements. While they share many functions in common, they should not be considered entirely interchangeable.

The number of available extensions and modules and the relatively simple configuration, even in mass hosting environments, make Apache servers the web server of choice for beginners. The Apache web server is configured using an .htaccess file. If you shy away from creating a completely new configuration file, you can use one of the existing htaccess converters.

With the Nginx server, the configuration takes place via a fixed configuration file that is located outside the web root. This fixed configuration file contains everything Nginx needs to know. The configuration file is permanently stored in the server's memory, so there is no need to try out the subdirectories. A configuration file with a curly, JS-like syntax is used for this.

However, both can be used in combination and you can get the best of both worlds. To do this, you connect an Nginx web server as a reverse proxy in front of the Apache server. The Nginx web server supplies the static content of the website, and for dynamic content, usually from PHP scripts, the request is forwarded to the Apache server.

Overview of differences

  • Apache servers run on all Unix-like systems and fully support Windows, but Nginx servers have limited support for Windows.
  • The Apache server uses a multi-threaded approach to processing client requests, while the Nginx server uses an event-driven approach.
  • In contrast to the Apache server, the Nginx server can process multiple requests at the same time when there is heavy web traffic.
  • Apache servers process dynamic content within the web server itself; with Nginx, a PHP interpreter takes over the request and returns the result.
  • Nginx is both a web server and a proxy server, Apache is just a web server.
  • Modules are loaded or unloaded dynamically in the Apache server; in the Nginx server, they must be compiled beforehand.

Conclusion

The advantage of Nginx is clearly its performance, which makes it more attractive for websites with high traffic. On the other hand, the simple and flexible configuration and its usability for Windows servers speak in favor of Apache, which makes it accessible to a broader spectrum of website operators.

Interesting links:

Differences between Apache and Nginx on Kinsta

When should you use which web server? More on t3n

Images: Canva


The author: Sascha Thattil works at YUHIRO and helps entrepreneurs and companies to easily set up programming teams in India. YUHIRO is a German-Indian company which provides IT companies, agencies and IT departments with software developers.

By author on February 16, 2021 / Web Development / Leave a comment