Nginx, fastcgi PHP Windows, 未指定输入文件
Nginx, fastcgi PHP Windows, No input file specified
运行 php-cgi 端口 9000
Netstat 给我
TCP 127.0.0.1:9000 DESKTOP-xxxxxxx:0 LISTENING
[php-cgi.exe]
nginx.conf
每个 php 文件都会给我这个 No input file specified.
错误...
将 SCRIPT_FILENAME
更改为 SCRIPT_NAME
但没有成功..
我在 Windows 10 Home x64
您需要使用 root
指令设置文档根目录,在您的 location ~ \.php$
块内或从外部 server
块继承。
解决方案可能是将 root c:/Users/Youri/PhpstormProjects;
行从 location /
块移到它上面的位置。
通常 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
是指定脚本完整路径的正确方法,而 SCRIPT_NAME
通常只是最后一个元素。
像这样:
server {
...
root c:/Users/Youri/PhpstormProjects;
location / {
index index.html index.htm index.php;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
在 windows PC 中使用绝对路径设置根指令。
检查路径中的大小写或任何键入错误。
重新加载nginx进程。
可能是root
路径问题。我在 Windows 上使用了反斜杠 \
并发现了这个问题。
server {
location ~ \.php$ {
- root C:\Users\name\ProjectOfPHP; # 404
+ root C:/Users/name/ProjectOfPHP; # Use this pattern
}
}
运行 php-cgi 端口 9000
Netstat 给我
TCP 127.0.0.1:9000 DESKTOP-xxxxxxx:0 LISTENING
[php-cgi.exe]
nginx.conf
每个 php 文件都会给我这个 No input file specified.
错误...
将 SCRIPT_FILENAME
更改为 SCRIPT_NAME
但没有成功..
我在 Windows 10 Home x64
您需要使用 root
指令设置文档根目录,在您的 location ~ \.php$
块内或从外部 server
块继承。
解决方案可能是将 root c:/Users/Youri/PhpstormProjects;
行从 location /
块移到它上面的位置。
通常 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
是指定脚本完整路径的正确方法,而 SCRIPT_NAME
通常只是最后一个元素。
像这样:
server {
...
root c:/Users/Youri/PhpstormProjects;
location / {
index index.html index.htm index.php;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
在 windows PC 中使用绝对路径设置根指令。 检查路径中的大小写或任何键入错误。 重新加载nginx进程。
可能是root
路径问题。我在 Windows 上使用了反斜杠 \
并发现了这个问题。
server {
location ~ \.php$ {
- root C:\Users\name\ProjectOfPHP; # 404
+ root C:/Users/name/ProjectOfPHP; # Use this pattern
}
}