-
-
Save alexglue/c90050b7f37af9486be8 to your computer and use it in GitHub Desktop.
Symfony2 minimal nginx+php-fpm configuration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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