Answer the question
In order to leave comments, you need to log in
What happens when a request is made to a web server?
I would like to see somewhere a brief instruction for beginners on the fingers of the type:
A request comes via http to DNS, DNS converts to ip, the server is located on the ip, Apache works on the server and looks at the request port, Apache starts the php interpreter, it interprets the file, etc. d.
I am especially interested in how the order of processing requests changes if the server does not have apache but also nginx, or only nginx, or instead of apache php-fpm or hhvm
Answer the question
In order to leave comments, you need to log in
so, since we have too many "how can it be" options, we have to break everything down into the following questions:
1) how does the request go from the browser to the http server. In this regard, we will consider apache as a black box. In this regard, the differences between apache, nginx, lighttpd, etc. we won't see.
here you can either google it in general, or break this question into: read about DNS, read about HTTP (these are generally different things). In parallel, it would be nice to read about the TCP / IP stack in general, and figure out what TCP is and what UDP is.
2) Next, in the case of PHP, we should read about PHP SAPI. That is, in the case of apache, our SAPI is provided by the apache2-mod-php module, and so on. and php-fpm is already a self-sufficient server and php process manager, which also provides its own SAPI. In fact, this is the thing that "parses" and prepares a request for php. Well, yes, it’s worth saying that there are already HTTP servers in PHP (as an alternative to php-fpm), these are ayres and php-pm and reactphp ... and judging by the dynamics, this will develop more and more.
3) as soon as we figured out how the browser works with the web server, and how php processes http, we must already start from a specific bundle in order to understand how the web server works with php. The previous point with more covers this, especially in the case of apache. But here php-fpm is a self-sufficient thing, and it doesn't need anything. And so nginx will just proxy requests to php-fpm.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question