Home > Operation and Maintenance > Nginx > How to customize PHP's $_SERVER variable in nginx

How to customize PHP's $_SERVER variable in nginx

王林
Release: 2023-05-20 23:52:04
forward
1422 people have browsed it

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;
}
Copy after login

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
......
)
Copy after login

What are the characteristics of php

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!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template