我是PHP和Laravel的新手。我已经从git克隆了一个Laravel项目,并保存了我的本地目录CCD_ 1。
NGINX folder C:nginx
php folder C:PHP
我的NGINX配置如下
server {
listen 80;
server_name localhost;
root C:/Projects/TestProject/public;
location / {
try_files $uri $uri/ /index.php?$query_string;
index index.html index.htm index.php;
}
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;
}
我还安装了composer和必要的dependencies。但当我尝试访问http://localhost/TestProject/public/index.php
时,它显示404
和No input file specified.
我创建了一个示例php文件Test.php,其中phpinfo()
int位于同一文件夹根目录中。当我访问http://localhost/TestProject/public/Test.php
时,它在浏览器上显示PHP信息,但网络显示url为404。我的PHP版本是7.4。
您必须在配置块中包含params文件:
include fastcgi.conf;
那么最后一块应该是:
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;
include fastcgi.conf;
}