有关我的设置的一些详细信息: p>
- I 我从默认的Nginx webroot提供静态webapp(HTML + JS) li>
- 我有一个在localhost上运行的PHP-FPM服务器:9000 li>
- 目标文件应该是/ FPM的api / webroot / index.php(总是 strong>,不需要try_files等。) li>
- 我需要转发所有 / api strong>和 / api-debug strong>调用到达localhost:9000,而/app/webroot/index.php应该处理所有这些请求。 li> ul> < p>我有以下工作 strong> Nginx配置: p>
upstream fastcgi_backend { server localhost:9000; keepalive 30; } \ n server { listen 80; location / { root / usr / share / nginx / html; index index.html index.htm; location~ ^ /(api | api -debug)/ { root / app / webroot; index index.php; try_files $ uri / api / in dex.php $ is_args $ args; 位置〜\ .php $ { fastcgi_pass fastcgi_backend; fastcgi_split_path_info ^(?:\ / api \ /)(。+ \。php)(。*) $; fastcgi_param SCRIPT_FILENAME / app / webroot / $ fastcgi_script_name; 包括fastcgi_params; } } } } code> pre>
我只是想让它变得更简单和有效,因为我现在看到它是一团糟。 我试图调整例如 p>
try_files $ uri / api / index.php $ is_args $ args; p> blockquote>
到 p>
try_files $ uri / api / webroot / index.php $ is_args $ args; p> blockquote>
它失败了...唯一的原因是/api/index.php包含/ api / webroot /index.php,但我觉得效率很低。 p>
我发现调试nginx配置很难,因为它不容易测试。 p>
非常感谢你 非常适合您的帮助! p> div>
- 我需要转发所有 / api strong>和 / api-debug strong>调用到达localhost:9000,而/app/webroot/index.php应该处理所有这些请求。 li> ul> < p>我有以下工作 strong> Nginx配置: p>