⬆️ ⬇️

Apache vs Nginx: a practical look

Apache vs nginx



Introduction



Apache and Nginx are the 2 most widely used open source web servers in the world. Together, they serve more than 50% of traffic on the entire Internet. Both solutions are capable of working with diverse workloads and interacting with other applications to implement a complete web stack.



Despite the fact that Apache and Nginx have many similar qualities, they cannot be considered as completely interchangeable solutions. Each of them has its own advantages and it is important to understand which web server to choose in which situation. This article describes how each of these web servers behaves under different conditions.



general review



Before diving into the differences between Apache and Nginx, let's take a quick look at the background of each of these projects.

')

Apache



Apache HTTP Server was developed by Robert McCul in 1995, and since 1999 it has been developed under the management of the Apache Software Foundation, the Apache Software Development Foundation. Since the HTTP server is the first and most popular project of the Fund, it is usually simply called Apache.



Apache web north has been the most popular web server on the internet since 1996. Due to its popularity with Apache, strong documentation and integration with third-party software.



Administrators often choose Apache because of its flexibility, power and prevalence. It can be expanded using a dynamically loaded module system and execute programs in a large number of interpreted programming languages ​​without the use of external software.



Nginx



In 2002, Igor Sysoev began work on Nginx in order to solve the C10K problem - a software requirement to work with 10,000 simultaneous connections. The first public release was released in 2004, the goal was achieved thanks to an asynchronous event-driven architecture.



Nginx began to gain popularity since the release due to its lightness (light-weight resource utilization) and the ability to easily scale to a minimum hardware. Nginx is excellent at delivering static content and is designed to transmit dynamic requests to other software designed to process them.



Administrators often choose Nginx because of its efficient use of resources and responsiveness under load, as well as the ability to use it as a web server and proxy.



Connection Processing Architecture



One of the most significant differences between Apache and Nginx is how they handle connections and respond to different types of traffic.



Apache



Apache provides several multi-processing modules (MPM) that are responsible for how the client’s request will be processed. This will allow administrators to define connection handling policies. Below is a list of Apache MPM modules:





Apache .



Nginx



Nginx Apache, , , . Nginx event-driven .



Nginx - . , . .



, , event loop . , . .



Nginx' . , CPU , .





, Apache Nginx .



Apache



Apache file-based . MPM.



Apache . - . Apache .



Apache . , .



Nginx



Nginx . PHP Nginx , . .



, Nginx , Nginx' (http, FastCGI, SCGI, uWSGI, memcache). , , .



, . , , , . . Apache , .





- Apache .



Apache



Apache , . , Apache , .htaccess.



, Apache .htaccess . -, URL' (URL rewrite), , .



, Apache, .htaccess . -, , -. , - .htaccess.



(CMS) -. , .



Nginx



Nginx .htaccess . Apache, .



.htaccess — . Apache .htaccess , - . , .



Nginx , , directory lookup (, ).



. Apache , . , .



, .htaccess Apache, .



URI



- .



Apache



Apache URI, . <Directory> <File>, — <Location>.



Apache -, . document root - , , . , .



Apache . <Location> URI . , .



Apache c , webspace, . -, , .htaccess . Apache URI- .



Nginx



Nginx , -, -. URI, .



Nginx . Nginx , URI.

, Nginx <server> <location>. <server> , , <location> URI, . , URI, .



(mapped) . Nginx server location, document root URI, .



( URI) , Nginx URI, -, . Nginx , . Nginx , .htaccess.





Apache, Nginx , .



Apache



Apache , , . Apache , , .



Apache . , , mod_php PHP- .



. : URL' (URL rewrite), , , , , , , , . .



Nginx



Nginx , Apache. Nginx , .



Nginx . , . , - .



, Nginx , , . .



Nginx , Apache: , , , , URL', -, , , , .



, ,



.



Apache



Apache . Apache, . Apache, .



- Apache. , .



Apache . Apache, - Apache - .htaccess.



Nginx



Nginx , .



- , . -, .



Nginx Apache, Nginx. Nginx Nginx.



Apache Nginx



Apache Nginx , . , .



Nginx Apache -. Nginx , Apache — . Nginx - .



Nginx , , PHP-, Apache, , Nginx', .



, Nginx . Apache , , Apache.



: Nginx , .





Apache, Nginx — , . .



, , . . , - , .

Source: https://habr.com/ru/post/267721/



All Articles