nginx interacts with php
1. The user sends an http request to the nginx server (the user and the nginx server perform a three-way handshake for a TCP connection)
2. nginx will judge the request based on the URI and suffix visited by the user
3. From the second step, it can be seen that the user requests dynamic content, and nginx will hand over the request to The fastcgi client sends the user's request to php-fpm through fastcgi_pass
If the user accesses static resources, it is simple. nginx directly returns the static resources requested by the user to the user.
4. After the wrapper receives the request transferred from php-fpm, the wrapper will generate a new thread to call the php dynamic program parsing server
5. PHP will return the query results to nginx
6. nginx constructs a response message and returns the result to the user
This is just one of nginx. The user request and the return of the user request result are performed asynchronously, that is, the user request The resources have been transferred once in nginx, and nginx can synchronize them, which is the parsed resources. The server directly returns the resources to the user without having to do a transfer in nginx.
Recommended tutorial: nginx tutorial
The above is the detailed content of How nginx and php interact. For more information, please follow other related articles on the PHP Chinese website!