1. First, add the variable values you want to add in the nginx configuration. The file content is as follows:
location ~ \.php$ { try_files $uri =404; root /data/www.shuchengxian.com/; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param ENVIRONMENT 'DEV'; #这个就是你要加的变量 include fastcgi_params; }
2. Restart the nginx service.
3. Use PHP to output the $_SERVER array to see if there are any added values.
Array ( [USER] => www [HOME] => /home/www [ENVIRONMENT] => DEV [REQUEST_TIME] => 1603264337 ...... )
1. Fast execution speed.
2. It has good openness and scalability.
3. PHP supports a variety of mainstream and non-mainstream databases.
4. Object-oriented programming: PHP provides classes and objects.
5. Fast version update.
6. It has rich functions.
7. Scalability.
8. Comprehensive functions, including graphics processing, encoding and decoding, compressed file processing, xml parsing, etc.
The above is the detailed content of How to customize PHP's $_SERVER variable in nginx. For more information, please follow other related articles on the PHP Chinese website!