minimal fastcgi config for 1 file?

Maxim Dounin mdounin at mdounin.ru
Thu Feb 13 14:29:13 UTC 2014


Hello!

On Thu, Feb 13, 2014 at 05:50:18AM -0800, Grant wrote:

> >> Is it OK to use a minimal fastcgi configuration for a single file like this:
> >>
> >> location ~ ^/piwik/piwik.php$ {
> >
> > It doesn't make sense to use regular expression here.  Instead,
> > use exact match location:
> >
> >     location = /piwik/piwik.php {
> 
> I'm only using one instance of location = or ^~ and that is on a very
> frequently used location.  Should I keep it that way for performance?
> The idea is that nginx won't have to evaluate all of the other
> locations when the frequently used location is accessed.

The "location =" is most effective and also clearest way to specify 
locations if you want to test for an exact match.

> >>     fastcgi_pass unix:/run/php-fpm.socket;
> >>     include fastcgi_params;
> >
> > The "fastcgi_params" file as shipped with nginx doesn't set the
> > SCRIPT_FILENAME parameter, and php will likely unable to handle
> > such a request.  Use "include fastcgi.conf;" instead if you don't
> > need SCRIPT_FILENAME customization.
> 
> I noticed my distro doesn't include any of the following in
> fastcgi_params and only the first of these in fastcgi.conf:
> 
> SCRIPT_FILENAME
> PATH_INFO
> PATH_TRANSLATED
> 
> They are all included in fastcgi_params in the example here:
> 
> http://wiki.nginx.org/PHPFcgiExample
> 
> Should they all be added to fastcgi_params?

No.  The idea is that fastcgi_params include basic parameters, and 
usable in configurations like:

    location / {
        fastcgi_pass ...
        fastcgi_param SCRIPT_FILENAME /path/to/script.php;
        fastcgi_param PATH_INFO $uri;
        include fastcgi_param;
    }

-- 
Maxim Dounin
http://nginx.org/



More information about the nginx mailing list