Here's a pair of config files that I use for Zend Framework applications. First, php.conf
, which I share between projects on my development workstation. I keep this at a directory above my sites
directory, right in the nginx config root (e.g. /usr/local/etc/nginx/php.conf
):
fastcgi_intercept_errors on;
# this will allow Nginx to intercept 4xx/5xx error codes
# Nginx will only intercept if there are error page rules defined
# -- This is better placed in the http {} block as a default
# -- so that in the case of wordpress, you can turn it off specifically
# -- in that virtual host's server block
location ~ \.php$
{
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_param APPLICATION_ENV development;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
fastcgi_read_timeout 60;
fastcgi_pass 127.0.0.1:9001;
fastcgi_index index.php;
}
And then the server
block that makes use of that:
server
{
listen 80;
server_name local.example.com;
root /var/www/example/public;
location /
{
index index.php;
try_files $uri $uri/ /index.php$is_args$args;
}
include php.conf;
}
In your case, I think the key bit is try_files $uri $uri/ /index.php$is_args$args;
, where we just pass the URL and query string wholesale to index.php
, and let it do the parsing.