gpt4 book ai didi

php - Directadmin + Nginx + php fpm + 位置 : File not found

转载 作者:搜寻专家 更新时间:2023-10-31 21:01:38 26 4
gpt4 key购买 nike

我在 Direct Admin 中有一个带有自定义位置的 nginx conf:

代码:

location /reset-password {
alias /home/**/domains/**.**/public_html/api/frontend-scripts/resetPassword;
include /usr/local/directadmin/data/users/**/nginx_php.conf;
}

这是行不通的; nginx 显示“找不到文件”。对于浏览器中的所有 PHP 相关文件。纯 HTML 工作正常。

我尝试了其他几种解决方案,即:

代码:

location /reset-password {
alias /home/**/domains/**.**/public_html/api/frontend-scripts/resetPassword;
# use fastcgi for all php files
location ~ \.php$
{
try_files $uri index.php;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include /etc/nginx/fastcgi_params;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /etc/nginx/nginx_limits.conf;
if (-f $request_filename)
{
fastcgi_pass unix:/usr/local/php56/sockets/**.sock;
}
}
}

他们都给出了“找不到文件”。在浏览器中。

所以它可能与 phpfpm 有关,但我别无选择。我做错了什么?

最佳答案

在 PHP 中使用 alias 总是有问题,因为 $document_root$fastcgi_script_name 语句不再有效。

你可以使用:

fastcgi_param SCRIPT_FILENAME $request_filename;

但是一个open bug in nginx使 try_filesalias 的使用有点不可预测。

我的首选解决方案是不可见地重写 URI,以便 root directive可以使用:

location ^~ /reset-password {
rewrite ^/reset-password(.*)$ /resetPassword$1 last;
}
location ^~ /resetPassword {
root /home/**/domains/**.**/public_html/api/frontend-scripts;
...
}

还要注意 ^~ 修饰符导致 these prefix location blocks优先于同一级别的其他正则表达式位置 block (例如,另一个 location ~\.php$ block )应该有一个。

关于php - Directadmin + Nginx + php fpm + 位置 : File not found,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41009066/

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