Where did the $ _ SERVER in php learn a tcpdump packet capture command a few months ago? I always want to try it if I have any problems. it's really a programmer's ultimate weapon. it's like a microscope, show all ugly bugs to you.
Why are there any questions in the question? Because I found that in different environments, the $ _ SERVER ["SERVER_NAME"] I obtained is different.
$ _ SERVER as the name suggests, it is the SERVER configuration, so I think it should be related to nginx configuration. The same is true.
Verification Method 1:
It is very easy to see through the phenomenon, by changing the nginx configuration, and then printing the variable in PHP.
Server {listen *: 8080 root/var/nginx server_name localhost ;}
Verification Method 2:
Use tcpdump to capture a request packet from nginx to php-fpm. use wireshark
Tcpdump tcp dst port 9000-I lo-s 0-w show &
We can see that nginx passed some server variables to php-fpm.
For details, refer to the fastcgi protocol.
You can find a configuration file named fastcgi_params in the nginx configuration file directory at the same level. nginx should pass the variables to PHP.