I'd prefer to use the following nginx config structure. It's cleaner:
location / {
try_files $uri $uri/ @phpsite;
}
location @phpsite {
include fastcgi_params;
... other fast_cgi directives
}
A bit more complex setup can be found in the popular silex project: http://silex.sensiolabs.org/doc/web_servers.html#nginx.
I see 2 problems in the original config file:
location ~ \.php$ {
try_files $uri =404;
...
}
- In regex '$' means matching at the end of the string. So it failed as stated in the comments by prodigitalson.
- That try_files directive inside the above fast_cgi location block should not be there because that location block is supposed to be handled by php alone. It's cleaner to remove that line.