CakePHP2をnginx+php-fpmでバーチャルホストで動かす場合の設定例
設定ファイルは/etc/nginx/conf.d/にhogehoge.cnfと拡張子をcnfにしたものが自動的に読み込まれます。
server_nameとrootのパスは各自環境に合わせて書き換えます。
/etc/nginx/conf.d/host.cnf
server { listen 80; server_name host_name; root /usr/share/nginx/host/app/webroot; index index.php index.html; #charset koi8-r; #access_log /var/log/nginx/log/host.access.log main; location / { try_files $uri $uri?$args $uri/ /index.php?$uri&$args /index.php?$args; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ \.php$ { try_files $uri =404; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #} } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ \.php$ { try_files $uri =404; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #} }