我有一个自定义位置的直接pipe理中的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的工作正常。
我已经尝试了几个其他的解决scheme,即:
码:
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有关,但我没有select。 我究竟做错了什么?
由于$document_root$fastcgi_script_name语句不再有效,因此在PHP中使用alias通常是有问题的。
你可以使用:
fastcgi_param SCRIPT_FILENAME $request_filename;
但是Nginx一个开放的bug使得使用alias的try_files有点不可预知。
我的首选解决方案是无形地重写URI,以便可以使用root指令 :
location ^~ /reset-password { rewrite ^/reset-password(.*)$ /resetPassword$1 last; } location ^~ /resetPassword { root /home/**/domains/**.**/public_html/api/frontend-scripts; ... }
另外请注意, ^~修饰符会使这些前缀位置块优先于同一级别的其他正则表达式位置块(例如另一个location ~ .PHP$块)。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。