いろいろ試行錯誤したけど最終的にこれ。
(MAMP Pro使った例です)
location ^~ /dashboard {
location ~ ^/dashboard/(img|css|js|files|components)/(.+)$ {
root /Applications/MAMP/htdocs/dashboard/app/webroot;
try_files /$1/$2 =404;
}
location ~ ^/dashboard/(.*)$ {
index index.php index.html;
set $new_uri /dashboard/app/webroot/$1;
try_files $new_uri $new_uri/ /dashboard/index.php?$args;
fastcgi_pass unix:/Applications/MAMP/Library/logs/fastcgi/nginxFastCGI_php7.0.12.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /Applications/MAMP/conf/nginx/fastcgi_params;
}
}
いろんなブログ記事を参考にしたけど、MAMP Proだとnginxのphpについてのlocation設定がデフォルトで先に書いてあったりして、ホスト毎の設定はその後だったため、MAMP Proのホスト毎のNginx設定は優先度が下がってうまいこといかないのがほとんどでした。
でもってlocationの優先順位について改めてちゃんと調べてデフォルトで書いてあるPHPのlocation設定よりも優先度高くなるように ^~
を使いました。
ここにたどり着くまでにいったい何時間ムダにしたんだろうか…orz