LoginSignup
0
0

More than 5 years have passed since last update.

NginxのサブディレクトリでNetCommons3(CakePHP2)を動かす

Last updated at Posted at 2017-02-17

いろいろ試行錯誤したけど最終的にこれ。
(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

参考

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0