symfony php configuration

shaktale nginx-forum at nginx.us
Wed Apr 29 19:21:48 MSD 2009


Hi all.

In a previous post, Igor says:

"If you have "if ($uri" in configuration, this means that your configuraiton
is far from optimal and has hidden agendas."

I'm using nginx + phpfpm + symfony framework and it's working fine.

I take my configuration from this list, from an older post related to symfony.

  location / {

    # If the file exists as a static file serve it directly without
    # running all the other rewite tests on it
    if (-f $request_filename) {
      expires max;
      break;
    }

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

  location /sf/ {
     root /usr/share/pear/data/symfony/web/;
  }


  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 /usr/local/nginx/conf/fastcgi_params;

    fastcgi_param  PATH_INFO        $path_info;
    fastcgi_param  SCRIPT_FILENAME  $document_root$script;
    fastcgi_param  SCRIPT_NAME      $script;
  }

Please, is there a more optimal configuration without "if $uri", using try_files ?

Thanks in advance.

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,1549,1549#msg-1549






More information about the nginx mailing list