gpt4 book ai didi

php - NGINX - 未指定输入文件

转载 作者:行者123 更新时间:2023-12-04 03:09:59 24 4
gpt4 key购买 nike

Just want to let everyone know before I posted this question I checked every single thread on stackoverflow about this issue.

目标:

在一个域下运行两个应用程序,第一个应用程序在根 (/) 下,第二个应用程序在 URI (/learn) 下。

http://example.com/ - first app
http://example.com/learn - second app

问题:

主应用程序运行完美,但学习应用程序显示的是“未指定输入文件”的白页。

我的文件结构:

/srv/users/serverpilot/apps/main/public/index.php
/srv/users/serverpilot/apps/learn/public/index.php

我的 NGINX 配置:

root "/srv/users/serverpilot/apps/main/public";

location ^~ /learn {
root "/srv/users/serverpilot/apps";
try_files $uri /learn/public/index.php?$query_string;
location ~ \.php$ {
add_header X-debug-message $document_root$fastcgi_script_name always;
include fastcgi_params;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass unix:/srv/users/serverpilot/run/learn.php-fpm.sock;
}
}

location / {
try_files $uri $uri/ /index.php?$args;
location ~ \.php$ {
include fastcgi_params;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass unix:/srv/users/serverpilot/run/main.php-fpm.sock;
try_files $uri =404;
}
}

In addition:

  1. I know the fastcgi_pass sockets are working because I've been running these two apps under different domains but in the same server in question.
  2. I added the add_header X-debug-message $document_root$fastcgi_script_name" always; to see what the response header would show, and it shows that the SCRIPT_FILENAME is /srv/users/serverpilot/apps/learn/public/index.php which exists and is the exact file I am trying to run.

最佳答案

天哪!多么疯狂的狩猎!

好的,这个配置不起作用的原因是因为除了 fastcgi_params 你还可以设置 php_value[doc_root] 这将覆盖你的 $document_root 常用于 SCRIPT_FILENAME 参数。因此,请始终检查您的 php.ini 文件,以确保当您拥有从不同目录提供的应用程序时,未设置 php_value[doc_root] 否则它不会选择它们.如果您只是从单个目录提供单个应用程序,则无需担心。

关于php - NGINX - 未指定输入文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46028755/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com