nginx FastCGI error Primary script unknown solution

  • 2020-05-07 20:53:04
  • OfStack

After successfully compiling and installing nginx 1.4, php 5.4 on centos and successfully starting nginx and php-fpm, access php prompts "File not found."

2013/10/22 20:05:49 [error] 12691#0: *6 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 192.168.168.1, server: localhost, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "192.168.168.133"

error resolution:
Find a place in the Nginx configuration file to define the call script file, such as:

fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;

Change to the following ($document_root) :
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

tip:
$document_root represents the value specified in the root directive for the current request. Such as:

location / {
       root   /usr/local/nginx/html;
       index  index.php index.html index.htm;
       fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}

Above $document_root configuration is against/usr/local nginx/html php file parsing in the directory.


Related articles: