我在 中有一个 AngularJS 应用程序,/home/app/front
在 中有一个 PHP 后端/home/app/back
。现在我想从 提供静态文件,/
从 提供 PHP/api/v1/
我尝试了以下配置,但没有成功。Nginx 抛出以下错误消息:FastCGI sent in stderr: "Primary script unknown"
server {
listen 80;
server_name localhost;
location / {
root /usr/share/nginx/html/wpplugins/frontend;
try_files $uri $uri/ /index.html;
}
location ^~ /api/v1/ {
root /usr/share/nginx/html/wpplugins/backend;
try_files $uri $uri/ /index.php?_url=$request_uri;
}
location ~ \.php {
fastcgi_index /index.php;
fastcgi_pass unix:/var/run/php5-fpm.sock;
include /etc/nginx/fastcgi_params;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}