server
{
server_name domainname.com;
root /srv/sites/domainname.com/httpdocs;
index index.php;
access_log /srv/sites/domainname.com/logs/access.log main;
error_log /srv/sites/domainname.com/logs/error.log info;
try_files $uri $uri/ /index.php?$query_string;
location ~ \.php$
{
try_files $uri $uri/ /index.php?$query_string =403;
include /usr/local/nginx/conf/fastcgi_params;
fastcgi_pass phpfpm;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
This will allow static files to be served appropriately, standalone .php files to be run, and anything requiring a frontloader to be passed on accordingly. This should work with most frontloader based frameworks, however certain ones will fail, e.g. symphony (no not symfony)...EDIT: Added change suggested by nbpoole to fix security vulnerability.