我想将任何api/*
路由传递给 php-fpm。特别是index.php
因为我使用 Symfony。这是唯一应该使用 php 的路径。其他任何内容都将从/usr/share/nginx/html/public
(仅 HTML 文件和 CSS)加载。
我已经尝试过,但出现错误:
FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream
Run Code Online (Sandbox Code Playgroud)
我的 nginx 配置如下:
upstream php {
server php:9000;
}
server {
listen 80 default_server;
server_name impressive.local;
index index.html index.php;
root /usr/share/nginx/html/public;
location /api {
root /usr/share/nginx/html/api;
try_files $uri /index.php;
}
location ~ \.php$ {
fastcgi_pass php;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi.conf;
}
}
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
php_1 | [13-Jan-2019 23:22:54] NOTICE: fpm is running, pid …
Run Code Online (Sandbox Code Playgroud)