Skip to content

Instantly share code, notes, and snippets.

@urre
Created Oct 30, 2012
Embed
What would you like to do?
PHP5-FPM configuration
# Pass all .php files onto a php-fpm/php-fcgi server.
location ~ \.(css|js|jp(e)?g|gif|png|swf|ico)$ {
expires 1y;
}
# unless the request is for a valid file, send to bootstrap
if (!-e $request_filename)
{
rewrite ^(.+)$ /index.php?q=$1 last;
}
location ~ \.php$ {
if (!-f $document_root$fastcgi_script_name){
rewrite ^ /index.php break;
}
# Zero-day exploit defense.
# http://forum.nginx.org/read.php?2,88845,page=3
# Won't work properly (404 error) if the file is not stored on this server, which is entirely possible wi$
# Comment the 'try_files' line out if you set up php-fpm/php-fcgi on another machine. And then cross you$
try_files $uri $uri/ /index.php?$args;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
#NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
include fastcgi_params;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
# fastcgi_intercept_errors on;
fastcgi_pass php;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment