NGINX - 未指定输入文件
NGINX - No input file specified
Just want to let everyone know before I posted this question I checked
every single thread on Whosebug about this issue.
目标:
运行 一个域下的两个应用程序,第一个应用程序在根目录 (/) 下,第二个应用程序在 URI (/learn) 下。
http://example.com/ - first app
http://example.com/learn - second app
问题:
主应用程序运行良好,但学习应用程序显示一个带有 "No input file specified." 的白页。
我的文件结构:
/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:
- 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.
- 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] 未在您设置时设置拥有从不同目录提供服务的应用程序,否则它不会选择它们。如果您只是从单个目录提供单个应用程序,您不必担心。
Just want to let everyone know before I posted this question I checked every single thread on Whosebug about this issue.
目标:
运行 一个域下的两个应用程序,第一个应用程序在根目录 (/) 下,第二个应用程序在 URI (/learn) 下。
http://example.com/ - first app
http://example.com/learn - second app
问题:
主应用程序运行良好,但学习应用程序显示一个带有 "No input file specified." 的白页。
我的文件结构:
/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:
- 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.
- 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] 未在您设置时设置拥有从不同目录提供服务的应用程序,否则它不会选择它们。如果您只是从单个目录提供单个应用程序,您不必担心。