Skip to content

Instantly share code, notes, and snippets.

@urre
Created October 30, 2012 19:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save urre/3982429 to your computer and use it in GitHub Desktop.
Save urre/3982429 to your computer and use it in GitHub Desktop.
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