#
# host.com
#
server {
listen 80;
server_name www.host.com;
rewrite ^ $scheme://host.com$request_uri? permanent;
}
server {
listen 80;
server_name host.com;
access_log /var/www/logs/host.com.access.log;
error_log /var/www/logs/host.com.error.log;
root /var/www/host.com/web;
index app.php; #for production frontend
location / {
try_files $uri $uri/ /app.php?$args;
}
location = /favicon.ico {
#log_not_found off;
access_log off;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}
location ~ /\.ht {
deny all;
}
location ~ \.php($|/) {
try_files $uri =404;
include fastcgi_params;
set $script $uri;
set $path_info "";
if ($uri ~ "^(.+\.php)($|/)") {
set $script $1;
}
if ($uri ~ "^(.+\.php)(/.+)") {
set $script $1;
set $path_info $2;
}
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors on;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_param SCRIPT_NAME $script;
fastcgi_param PATH_INFO $path_info;
}
Origin: https://gist.github.com/879378
Wednesday, May 9, 2012
Symfony nginx configuration
Simple configuration for Nginx hosted symfony2 project