location ~ \.php($|/) {
    fastcgi_pass   unix:/dev/shm/php.sock;
    include        fastcgi_params;
    set $script $uri;
    set $path_info "";
    if ($uri ~ "^(.+?\.php)(/.+)$") {
        set $script $1;
        set $path_info $2;
    }
    fastcgi_param SCRIPT_NAME $script;
    fastcgi_param PATH_INFO $path_info;
    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;

}

> 其中 location ~ \.php($|/) { 后面的($|/) 不要忘记了