Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

File Not Found when running PHP with Nginx

Tags:

php

nginx

Recently I installed the latest version of Nginx and looks like I'm having hard time running PHP with it.

Here is the configuration file I'm using for the domain:

server { listen       80; server_name  localhost;  location / {     root   /usr/share/nginx/html;     index  index.php; }  error_page   500 502 503 504  /50x.html; location = /50x.html {     root   /usr/share/nginx/html; }  location ~ \.php$ {     fastcgi_pass   127.0.0.1:9000;     fastcgi_index  index.php;     fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;     include        fastcgi_params; } 

}

Here is the error I'm getting on the error log file:

FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream 
like image 394
user2298995 Avatar asked Jul 23 '13 11:07

user2298995


People also ask

What is 404 not found Nginx?

Essentially, the “404 error” indicates that your or your visitor's web browser was connected successfully to the website server or the host. However, it was unable to locate the requested resource, such as filename or any specific URL.

How does PHP-FPM work with Nginx?

Install PHP-FPM It needs a PHP module like PHP-FPM to efficiently manage PHP scripts. PHP-FPM, on the other hand, runs outside the NGINX environment by creating its own process. Therefore when a user requests a PHP page the nginx server will pass the request to PHP-FPM service using FastCGI.


1 Answers

Try another *fastcgi_param* something like

fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html$fastcgi_script_name; 
like image 133
deagh Avatar answered Sep 29 '22 14:09

deagh