這個錯誤很常見,很明顯找不到文件。
原因是php-fpm找不到SCRIPT_FILENAME里執行的php文件,所以返回給nginx 404 錯誤。
那么兩種情況要么文件真的不存在,要么就是路徑錯誤。
location / { root /var/www/example.com; index index.html index.htm index.pl; }
如果配置文件這樣的,那么明顯不好,也就是在
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; }
這里的document就找不到document_root,所以可以把root放在location外面試試看或者在
location ~ \.php$ {}
里面加上root.
如果文件真的不存在的話,因為nginx檢查$uri是不是.php結尾,不檢查是不是存在,所以找不到時候就返回404錯誤。“No input file specified”
如果是這樣的話,在配置文件種用try_files就可以檢查是否存在了。
不存在就返回404.
location ~ .php$ { try_files $uri =404; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; ... }