The following configurations are supported for phpfastcgi:
server {
Listen 8000;
server_name localhost;
Root f:/home/projects/test;
Index index.php;
Location/{
Index index.php; # #可以有多个, Space separated
}
Location ~ \.php$ {
Fastcgi_pass 127.0.0.1:9000;
Fastcgi_index index.php;
Fastcgi_param script_filename $document _root$fastcgi_script_name;
Include Fastcgi_params;
}
}
Explanatory notes:
1, Location ~ \.php$ matching to php file for fastcgi operation
2, Fastcgi_pass 127.0.0.1:9000; Specifies the ID and port number of the Nginx interaction with the fastcgi, which is the port that the fastcgi listens to
3, Fastcgi_param script_filename $document _root$fastcgi_script_name;
This declares a fastcgi parameter,
The parameter name is called Script_filename (that is, the value of $_server[' Script_filename ' in PHP), which indicates which PHP script the target process will execute
$document _root, $fastcgi _script_name are Nginx constants. The arguments declared here will communicate to php-cgi,php-cgi to initialize some of the constant variables of PHP, for example: $_server[' Request_uri '],$_server[' script_filename '],$_server[ ' Query_string '] ....
4, include fastcgi_params; this is the inclusion of all Nginx constants, passed to php-cgi.
This can also be set, including a configuration file such as: include fcgi.conf;
Fastcgi_param script_filename $document _root$fastcgi_script_name;
Fastcgi_param Request_uri $request _uri;
Fastcgi_param query_string $query _string;
......
Some Nginx constants are explained, with HTTP://127.0.0.1:8000/?TEST=123&TEST2=ABC as an example:
Parameter,test=123&test2=abc; for $args #这个变量等于请求行中 (GET request)
$content _length #请求头中的Content-length field;
$content _type #请求头中的Content-type field;
$document _root #当前请求在root指令中指定的值, the physical root path of the file, f:/home/projects/test;
$document _uri #同 $uri;
$uri #不带请求参数的当前URI, $uri does not contain a hostname, this example is "/". This value may be inconsistent with $request_uri. $request _uri is the value that the browser sends over, and the value is not changed. The value may be a value after rewrite. For example after doing the internal redirects. Many frameworks and pseudo-static are used in rewrite. $_server[' Request_uri ' is often the key to some framework initialization, $request the immutability of the _uri guarantees this.
$host #请求主机头字段, otherwise the server name. 127.0.0.1
$query _string #同 $args;
$request _method #GET或POST;
$remote _addr #客户端的IP地址;
$remote _port #客户端的端口;
$server _addr #服务器地址 127.0.0.1
$server _name #服务器名称, localhost;
$server _port #8000;
$request _filename #当前请求的物理文件的名称, this example is f:/home/projects/test/index.php. This value can be changed by redirection.
$request _uri #包含请求参数的原始URI, does not contain host name, determined by the client request, cannot be modified. "/?test=123&test2=abc".
Nginx configuration: Support Phpfastcgi,nginx and php-cgi communication, partial Nginx constant explanation