drupal try_files php fastcgi

Igor Sysoev is at rambler-co.ru
Mon Mar 16 20:12:43 MSK 2009


On Mon, Mar 16, 2009 at 09:51:55AM -0700, Cliff Wells wrote:

> http://wiki.nginx.org/NginxJoomla
> 
> I find that basic recipe works for a lot of PHP frameworks.

Does Joomla require "/index.php?q=$request_uri" ?
When I have checked on their site, just /index.php was enough.

It's better to use try_files:

root  /path/to/root;

location / {
    try_files      $uri  $uri/  @fallback;
}

location ~ \.php$ {
    try_files      $uri  @fallback;

    fastcgi_pass   ...;

    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    # or just
    #    fastcgi_param  SCRIPT_FILENAME  $document_root$uri;
    # as here $fastcgi_script_name == $uri
    fastcgi_param  QUERY_STRING     $query_string;

    # other fastcgi_param's
}

location @fallback {
    fastcgi_pass   ...;

    fastcgi_param  SCRIPT_FILENAME  $document_root/index.php;
    fastcgi_param  QUERY_STRING     q=$request_uri;

    # other fastcgi_param's
}

Probably, you can use omit @fallback:

location / {
    try_files      $uri  $uri/  /index.php?q=$request_uri;
}

location ~ \.php$ {
    try_files      $uri  /index.php?q=$request_uri;
    ...
}


> On Mon, 2009-03-16 at 09:26 -0700, mike wrote:
> > 2009/3/16 Igor Sysoev <is at rambler-co.ru>:
> > 
> > > Have you @drupal location ?
> > 
> > This is one thing I want to get up on the wiki cookbook, a simple
> > 
> > @wordpress
> > @drupal
> > 
> > etc.
> > 
> > Simple being the key word.
> > 
> > A lot of people do wordpress crap with wp-content/*.js and all these
> > other filters and all you need is a simple
> > 
> > if (!-e $request_filename) {}
> > or
> > try_files $uri $uri/ @wordpress
> > or
> > try_files $uri $uri/ /path/to/main/wordpress/index.php
> > 
> > etc.
> > 
> > right now i run my blog using this:
> > 
> > error_page 404 = /wordpress/index.php?q=$request_uri;
> > 
> > works like a charm. i do want to start using try_files as I assume
> > that is more efficient and not kind of a silly hack "hey, if it's a
> > 404, use -this- as the page handler!"
> > 
> 

-- 
Igor Sysoev
http://sysoev.ru/en/





More information about the nginx mailing list