Custom settings with PHP

Hello!

On Tue, Jul 12, 2011 at 10:40:41AM -0400, locojohn wrote:

and

fastcgi_param PHP_VALUE “include_path=${include_path}:/my/other/path”;

and neither works, hence I wrote here.

As already replied in russian list, currently (going to be fixed)
this may be done only with a hack like

geo $x {
    default "${include_path}:/my/other/include/path";
}

fastcgi_param PHP_VALUE $x;

which relies on the fact that geo module doesn’t support
variables.

No idea how php will handle this though, probably Antonio is right
and this won’t work anyway.

Maxim D.

Hmm, never tried that, using a variable. Don’t
know if the $ needs to
be escaped.

You’ll have to try it.

Of course I tried both:

fastcgi_param PHP_VALUE “include_path=${include_path}:/my/other/path”;

and

fastcgi_param PHP_VALUE “include_path=${include_path}:/my/other/path”;

and neither works, hence I wrote here.

Andrejs

Posted at Nginx Forum:

Maxim D. Wrote:

No idea how php will handle this though, probably
Antonio is right
and this won’t work anyway.

It works, just tested it with php-fpm. php-fpm substitutes ${var} with
the value for “var” in the master .ini file (php.ini). So constructs
like “${include_path}:/my/other/path” are OK to pass to the php-fpm
environment, and these will be interpreted correctly. The only trouble
is that the “geo” hack is kinda dirty indeed, especially so that all
these variables have to be explicitly declared then in the http section,
as the “geo” directive must be declared on the “http” level.

Antonio, I am certainly aware that one can write an auto_prepend_file
PHP script that will set all these variables correctly, but I prefer to
use server settings and skip auto_prepend_file overhead, if possible.
Turns out it is possible on the php-fpm level, and not currently on the
nginx level. Also, implementation of your suggestion means either
changing the source code of the scripts on a number of sites and making
it difficult to maintain/upgrade, or, as stated above, having
auto_prepend_file overhead for every php call. No good and IMHO
absolutely unnecessary and also pretty ugly, compared to what is
possible with just passing the right string to the environment.

Let’s wait for the nginx update!

Andrejs

Posted at Nginx Forum:

Hello Maxim,

Maxim D. Wrote:

variables.
Has this been fixed in 1.7.x? Eg can I now use PHP variables in the
fastcgi_param arguments, e.g. maybe with escaping character?

fastcgi_param PHP_ADMIN_VALUE “open_basedir=${open_basedir}”;

Andrejs

Posted at Nginx Forum: