Minimal fastcgi config for 1 file?

Is it OK to use a minimal fastcgi configuration for a single file like
this:

location ~ ^/piwik/piwik.php$ {
fastcgi_pass unix:/run/php-fpm.socket;
include fastcgi_params;
}

  • Grant

Hello!

On Wed, Feb 12, 2014 at 03:26:21PM -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 {
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.


Maxim D.
http://nginx.org/

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.

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?

  • Grant

If you want to run Piwik in a subdirectory of the webroot, then check
this
post
on how to run Piwik and Drupal together.

The idea is the same for running Piwik with any other PHP based
application.

https://groups.drupal.org/node/407348#comment-1012438

----appa

Hello!

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

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.

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 D.
http://nginx.org/

}

Should the wiki example be switched from fastcgi_param to fastcgi.cfg:

http://wiki.nginx.org/PHPFcgiExample

Also, PATH_INFO and PATH_TRANSLATED appear in the wiki but don’t
appear in the shipped files. Should they be removed from the wiki?

  • Grant

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs