Привожу свой вариант, в связке с php-fpm
server {
listen 80;
server_name your.site.ru;
charset utf-8;
root /usr/local/www/nginx/build;
index index.html index.htm index.php;
location / {
try_files $uri $uri/ /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/local/www/nginx-dist;
}
location ~ \w+\.php$ {
#вот тут лучше заменить на юникс сокет
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_script_name;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
location ~ ^/protected/ {
deny all;
}
}