Where does $ _ SERVER come from in php?

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.