Differences between Fastcgi_Params and fastcgi.conf

fastcgi.conf

Comparefastcgi.confandfastcgi_paramsText It can be seen that there are only the following differences:

Java code

  • tctq4master @ddd:/etc/nginx$diff fastcgi.conf fastcgi_params

  • < span style="color:#000000;">2d1

  • < fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

  • 25a25,26

  • >

  • > fastcgi_param SCRIPT_FILENAME $request_filename;

  • ol>

    iefastcgi.confOnly more thanfastcgi_paramsone more line

    Java code

    1. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

    < /p>

    Originally onlyfastcgi_paramsFile,fastcgi.confYes span>nginx 0.8.30 (released: 15t h of December 2009)Introduced. Mainly to solve the following problems (reference:http://www.dwz .cn/x3GIJ):

    OriginalNginx onlyfastcgi_params, later I found that many people used hard-coded methods when defining SCRIPT_FILENAME.

    For example, fastcgi_param SCRIPT_FILENAME /var/www/foo$fastcgi_script_name.

    So it was introduced for standard usage fastcgi.conf.

    After this, a question arises:

    Why do we have to introduce a new configuration file instead of modifying the old one?

    This is becausefastcgi_paramThe instruction is array type, and the same as the ordinary instruction: the inner layer replaces the outer layer;

    The difference with ordinary commands is: when used multiple times at the same level At the time, it is to add rather than replace.

    In other words, if in Define twice at the same levelSCRIPT_FILENAME, then they will all be sent to the backend, which may cause some potential problems. In order to avoid such situations, a new configuration file was introduced.

    Therefore, the following method is no longer recommended (searched, a lot of articles on the Internet, andnginx.confThe default configuration also uses the following method) :

    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

    include fastcgi_params;

    Use the latest method:

    include fastcgi.conf;

    The PHP problem is in the following two ways, Choose the second one

    location ~ \.php$ {

    root root html;

    fastcgi_pass 127.0.0.1:9000; gi _index

    fast index.php;

    fastcgi_para m SCRIPT_FILENAME /scripts$fastcgi_script_name;

    include

    p> root root html;

    fastcgi_pass 127.0.0.1:9000;

    root

    FILE p> include fastcgi.conf;

    Original URL: http://www.cnblogs.com/skynet/p/4146083.html

    ============================= ==============================================

    Java code

  • fastcgi_param SCRIP T_FILENAME $document_root$fastcgi_script_name;

  • This sentence is actually to define the server variables used in php-$_SERVER

    http://wiki.nginx.org/NginxHttpFcgiModule There is a sentence under this URL:

    This module allows Nginx to interact with FastCGI processes and control what parameters are passed to the process.

    means “server” to your cgi processing php Pass some of the parameters he needs in the past, and at least the following two parameters php can be executed.

    The following is an example

    Below is an example of the minimally necessary parameters for PHP:

    Java code

  • fastcgi_param SCRIPT_FILENAME /home/www/scripts/php$fastcgi_script_name;

  • < span style="color:#000000;">

  • fastcgi_param QUERY_STRING $query_string;


  • Parameter SCRIPT_FILENAME is used by PHP for determining the name of script. to execute, and QUERY _STRING contains the parameters of the request.

    So we are not defining When SCRIPT_FILENAME is a system variable phpI can’t explain and execute it

    this variable The definition can be written in the nginx configuration file nginx.conf or it can be written externally and included in nginx.conf by means of include.

    Leave a Comment

    Your email address will not be published.