fastcgi_param

Sets parameters for FastCGI requests in NGINX.

Syntaxfastcgi_param name value; [value];
Defaultnone
Contexthttp, server, location
Arguments2-3

Description

The fastcgi_param directive is utilized within the NGINX configuration to set environment variables that are passed to FastCGI servers. By default, it is used in contexts like http, server, and location, allowing for flexibility in configuring FastCGI behaviors for different application routes. The directive accepts two or three parameters, where the first parameter is the name of the variable, the second is its value, and optionally, a third parameter can be used to specify if the value should be taken from a request header.

When the fastcgi_param directive is employed, it essentially communicates information relevant to the processing of a FastCGI request. For example, you can set parameters like SCRIPT_FILENAME, which indicates the script to execute on the FastCGI server. This directive ensures that the necessary variables are available to the FastCGI application to properly respond to the user's request. It is particularly useful when you want to explicitly define how certain variables should be handled by your FastCGI application's logic.

It’s important to note that fastcgi_param will overwrite any parameters of the same name already set within the configuration, which allows for granular control over the environment passed to the FastCGI handler, thereby avoiding conflicts or unintended behaviors in variable values.

Config Example

location ~ \.php$ {
    include fastcgi_params;
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}

Make sure the variable names are valid and correctly specified since misspellings can lead to unexpected behavior.

Be cautious with overwriting existing parameters; ensure intended values are set explicitly if needed.

← Back to all directives