nginx PHP parsing solutions being given program

[root @ Server-2 log] # tail -f nginx / error.log
2019/07/31 01:51:02 [error] 26151 # 0: * 52 Sent in FastCGI stderr: "Unknown Primary Script" Reading the while the Response header upstream from, Client: 192.168.1.124, Server: localhost, Request: "GET /test.php HTTP / 1.1", upstream: "FastCGI: //127.0.0.1: 9000", Host: "192.168.1.136"
nginx parse PHP when the page can not be displayed out of view nginx log, the error message above;
View Profile
reason:
in fastcgi_params file (and nginx.conf file in the same directory) defined in a number of variables associated with fastcgi program, when nginx fastcgi interface to send via it is requested to go to a defined place to resolve the corresponding variable value, and then to php to deal with, obviously, if fastcgi can not get the appropriate value, then he will not be able to forward the request to the corresponding php program, it can not resolve.

The key to this problem lies in "Primary script unknown" master script is unknown, which is defined fastcgi can not find the script to be executed, the default configuration file fastcgi_params defined variable and not $ fastcgi_script_name this variable, but defined in fastcgi.conf a. So we either include this fastcgi.conf file, or to construct the fastcgi_params in the SCRIPT_FILENAME and fastcgi.conf in the value of the same, plus $ document_root parameter (the value of the parameter represents the value of the site root directory that line).
Solution 1
in the last line of the configuration file that contains fastcgi.conf configuration, the following results

 1    location ~ \.php$ {
 2             root           html/wordpress;
 3             fastcgi_pass   127.0.0.1:9000;
 4             fastcgi_index  index.php;
 5             fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
 6             include        fastcgi_params;
 7             include        fastcgi.conf; 
 8     }

Solution 2
Ba fastcgi_param SCRIPT_FILENAME / scripts $ fastcgi_script_name; this line instead: fastcgi_param SCRIPT_FILENAME $ document_root $ fastcgi_script_name;

1     location ~ \.php$ {
2           root           html/wordpress;
3           fastcgi_pass   127.0.0.1:9000;
4            fastcgi_index  index.php;
5           fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
6           include        fastcgi_params;
7    }

Guess you like

Origin blog.51cto.com/14101466/2429115