nginx configuration for symfony projects

Documenting my ngnix configuration for new symfony projects, if you got ideas for tweaking this further do leave a comment.

server {
    listen   80;
    server_name  be.aha.sulphur.local;
    root  /websites/aha-be/trunk/web;
    index index.php;
    charset utf-8;

    access_log  /var/log/nginx/be.aha.sulphur.access.log;

    location / {
          root  /websites/aha-be/trunk/web;
          index  index.php;

          if (-f $request_filename) {
            expires max;
            break;
          }

          if ($request_filename !~ "\.(js|htc|ico|gif|jpg|png|css)$") {
            rewrite ^(.*) /index.php last;
          }
    }

    location ~ \.php($|/) {
        set  $script     $uri;
        set  $path_info  "";

        if ($uri ~ "^(.+\.php)(/.+)") {
                set  $script     $1;
                set  $path_info  $2;
        }

        fastcgi_pass 127.0.0.1:9000;
        include /etc/nginx/fastcgi_params;
        fastcgi_param SCRIPT_FILENAME /websites/aha-be/trunk/web$script;
        fastcgi_param PATH_INFO $path_info;
        fastcgi_param SCRIPT_NAME $script;
        fastcgi_intercept_errors on;
    }

    location /sf/ {
        root /opt/vs/php-5.3.2/lib/php/data/symfony/web/;
        expires max;
    }

}

About rp

Architect for large, highly scalable LAMP applications and Technical Manager with special focus on metrics based continuous improvement of teams and products. Rajat has close to a decade of experience of a very wide range of skills related to infrastructure, middleware, app servers all the way to front-end technologies and software development methodologies including agile, iterative waterfall, waterfall as well as ah-hoc startup using the right approach in the right context to reduce time to market.