Answer the question
In order to leave comments, you need to log in
How does a webserver and php work?
I have been working as a web developer for a long time, and to be honest, I have never delved into the work of a web server, and there were no such tasks.
Now I want to close the gap in my knowledge, I'll figure out how a web server works, what layers it consists of, and what chain of interaction.
I have always used the classic web server scheme: apache+nginx.
And all I know is
Answer the question
In order to leave comments, you need to log in
Apache has a mod_php module that handles the code.
nginx\lighttpd does not have a module and they need a separate service\server to which they will pass the code via TCP or unix socket.
For php it is php-fpm
Once again: two web servers is an obvious crutch, caused only by the curvature of the user's hands, but by no means a technical necessity.
The web server, of course, only needs one.
The classic scheme in 2020 is one web server and PHP connected via FastCGI PHP.
It can be either Nginx+PHP-FPM
or Apache MPM Event+PHP-FPM. If you install Apache in modern distributions, then this option is installed by default.
In the end, it all comes down to the mammoth-old CGI protocol: the web server redirects the request to the handler (in this case, PHP), the handler returns the HTTP headers and (optionally) the response body, the web server gives them to the client.
In its simplest form, a separate web server is not required, see built-in server in PHP.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question