Skip to content

Instantly share code, notes, and snippets.

@pasela
Created June 28, 2012 03:25
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 pasela/3008756 to your computer and use it in GitHub Desktop.
Save pasela/3008756 to your computer and use it in GitHub Desktop.
nginx configuration example for Symfony2
#
# nginx configuration example for Symfony2
#
server {
listen 80;
server_name symfony2-example;
root /var/www/sf2/web;
access_log /var/log/nginx/sf2.access.log;
error_log /var/log/nginx/sf2.error.log;
rewrite ^/app\.php/?(.*)$ /$1 permanent;
location / {
index app.php;
try_files $uri @rewriteapp;
}
location @rewriteapp {
rewrite ^(.*)$ /app.php/$1 last;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass 127.0.0.1:9000;
}
location ~ \.php/ {
include fastcgi_params;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass 127.0.0.1:9000;
}
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
log_not_found off;
access_log off;
}
#error_page 404 /404.html;
#location = /404.html {
# root /usr/share/nginx/html;
#}
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /(\.ht|\.user.ini|\.git|\.hg|\.bzr|\.svn) {
deny all;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment