Re: интерпретация переменных внутри PHP VALUE и PHP ADMIN VALUE для PHP-FPM

António P. P. Almeida perusio на
Ср Июл 13 14:59:41 UTC 2011

On 13 Jul 2011 10h57 WEST, nginx-forum at wrote:

привет Andrejs,

> Hi Appa,
> For starters, which version of nginx and PHP are you using?  I am
> using nginx 1.0.4 and PHP 5.3.6.

Same here: I'm using 5.3.6-12 debian testing/unstable PHP packages.

> Next, in the nginx configuration I do:
> http {
> [...]
> # geo directive must be set on the http level
> geo $x {
> default "${include_path}:/my/other/include/path";
> }
> [...]
> }


> then, in a virtual host configuration:
> server {
> [...]
> # php-fpm upstream
> location ~ ^(?<SCRIPT_FILENAME>.+\.php)(?<PATH_INFO>[^?]*)$ {
> include /etc/nginx/fastcgi_params;
> fastcgi_param SCRIPT_FILENAME $document_root$SCRIPT_FILENAME;
> fastcgi_param PATH_INFO $PATH_INFO;
> fastcgi_param PATH_TRANSLATED $document_root$PATH_INFO;

> # set site-specific php configuration parameters
> fastcgi_param PHP_VALUE $x;
> if (-f $document_root$SCRIPT_FILENAME) {
> fastcgi_pass phpfarm;
> }

I'm not using PATH_INFO but rather a much more simple approach. This
is just a test.

location /fastcgi-test {
  fastcgi_pass phpcgi;

There's an include at the http level of a fastcgi configuration:

### Generic fastcgi configuration.
include fastcgi_params;
fastcgi_buffers 256 4k;
fastcgi_intercept_errors on;
## allow 4 hrs - pass timeout responsibility to upstream.
fastcgi_read_timeout 14400; 
fastcgi_index index.php;
## Hide the X-Drupal-Cache header provided by Pressflow.
fastcgi_hide_header 'X-Drupal-Cache';
## Hide the Drupal 7 header X-Generator.
fastcgi_hide_header 'X-Generator';

Where fastcgi_params is:

fastcgi_param  QUERY_STRING       $query_string;
fastcgi_param  REQUEST_METHOD     $request_method;
fastcgi_param  CONTENT_TYPE       $content_type;
fastcgi_param  CONTENT_LENGTH     $content_length;

fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;
fastcgi_param  REQUEST_URI        $request_uri;
fastcgi_param  DOCUMENT_URI       $document_uri;
fastcgi_param  DOCUMENT_ROOT      $document_root;
fastcgi_param  SERVER_PROTOCOL    $server_protocol;

fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
fastcgi_param  SERVER_SOFTWARE    nginx/$nginx_version;

fastcgi_param  REMOTE_ADDR        $remote_addr;
fastcgi_param  REMOTE_PORT        $remote_port;
fastcgi_param  SERVER_ADDR        $server_addr;
fastcgi_param  SERVER_PORT        $server_port;
fastcgi_param  SERVER_NAME        $server_name;
fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;

## PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param  REDIRECT_STATUS    200;

The test file is just:
echo -e "<?php\n phpinfo();" > index.php

Like I reported there's an error generated by php-fpm that shows up in
the php-fpm log.


> Then I created a test.php file in the document root with the
> following contents:
> <?
> printf("include_path is: \"%s\"\n", get_include_path());
> ?>
> And when calling the script, it outputs: 
> ".:/usr/share/php:/my/other/include/path", so it works for me.
> Let's find out why it doesn't work for you?

I'm having problems understanding how a PARAM type message can be sent
from the upstream (fpm in this case) to the server so that we can use
it's value on the config. I'm mostly ignorant regarding the details of
FCGI implementations, particularly Nginx FCGI module, but I'm under
the (perhaps erroneous) impression that the parameters are sent from
the server to the upstream and are not sent back from the upstream to
the server. Is it so?

As I understand it for the expansion of include_path to work there has to
be another variable that contains its value as string so that it
can be concatenated. Is it not?


Подробная информация о списке рассылки nginx-ru