Skip to content

Instantly share code, notes, and snippets.

@alexglue
Forked from leon/nginx.conf
Last active August 29, 2015 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexglue/c90050b7f37af9486be8 to your computer and use it in GitHub Desktop.
Save alexglue/c90050b7f37af9486be8 to your computer and use it in GitHub Desktop.
Symfony2 minimal nginx+php-fpm configuration
upstream symfony2-php-fpm {
server unix:/var/run/php5-fpm.sock;
#server 127.0.0.1:9001;
}
server {
listen 80;
server_name sitename;
root /var/www/$host/web;
error_log /var/log/nginx/sitename.error.log;
access_log /var/log/nginx/sitename.access.log;
set $is_dev 1;
set $core 'app.php';
if ( $is_dev ) {
set $core 'app_dev.php';
}
rewrite ^/app(_dev)?\.php/?(.*)$ /$2 permanent;
location / {
index $core;
try_files $uri @rewriteapp;
}
location @rewriteapp {
rewrite ^(.*)$ /$core/$1 last;
}
# Deny all . files
location ~ /\. {
deny all;
}
location ~ ^/(app|app_dev|config)\.php(/|$) {
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_index $core;
send_timeout 1800;
fastcgi_read_timeout 1800;
fastcgi_pass symfony2-php-fpm;
}
# Statics
location /(bundles|media) {
access_log off;
expires 30d;
try_files $uri @rewriteapp;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment