一般的なNginx + PHPエラーメッセージ “入力ファイルが指定されていません。”
nginx.conf
http {
include mime.types;
default__type application/octet-stream;
server {
listen 80;
server__name localhost;
location/{
root www;
index index.html index.htm;
}
location ~ \.php$ {
fastcgi__pass 127.0.0.1:9999;
fastcgi__index index.php;
fastcgi__param SCRIPT__FILENAME $document__root$fastcgi__script__name;
include fastcgi__params;
}
}
}
Nginxでテスト済み1.12.1 PHP 7.1
解決策
PHPは
.php`ファイルを見つけることができません。なぜなら
location/{}
のルートファイルパスは
location〜\ .php $ `には適用されないからです。
それを解決するには、ルートファイルパスを次のようにserverブロックに移動します。
nginx.conf
http {
include mime.types;
default__type application/octet-stream;
server {
listen 80;
server__name localhost;
# Move the root file path to server block.
root www;
location/{
#root www;
index index.html index.htm;
}
location ~ \.php$ {
fastcgi__pass 127.0.0.1:9999;
fastcgi__index index.php;
fastcgi__param SCRIPT__FILENAME $document__root$fastcgi__script__name;
include fastcgi__params;
}
}
}
参考文献
-
リンク://nginx/nginx-php-on-windows/[WindowsのNginx + PHP]
-
https://www.nginx.com/resources/wiki/start/topics/examples/phpfastcgionwindows/
[PHP-FastCGI
Windows上で]