I
I
Ilya Myasin2017-04-27 00:15:26
PHP
Ilya Myasin, 2017-04-27 00:15:26

How does fastcgi_param php_admin_value work?

Hey! Tell me, do I understand correctly what happens to the fastcgi_param PHP_ADMIN_VALUE values ​​in the nginx - php-fpm bundle?
For example, we have this piece of config:

location = /a.php {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_param  SCRIPT_FILENAME $document_root$uri;
            fastcgi_param  PHP_ADMIN_VALUE "open_basedir = $document_root:/test-$msec";
            include        fastcgi_params;
}

location = /b.php {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_param  SCRIPT_FILENAME $document_root$uri;
            include        fastcgi_params;
}

The a.php and b.php files show open_basedir:
<?php
echo ini_get('open_basedir');

And fpm pool with total processes: 3 .
When we open /a.php, our strange open_basedir is passed to one of the pool processes, and the script shows it. When we open /b.php and press F5 several times, we see in turn either a blank or the value that we saw on the /a.php page. If we update /a.php several times, and then update /b.php, we will watch three values ​​passed from the /a.php location in a circle.
That is, the values ​​from fastcgi_param PHP_ADMIN_VALUE ... are stored internally by the process, and if they are not passed explicitly, the last saved ones will be used on the next request processed by this process?
Do I understand correctly that if we have only one location that sends a request to fpm, we will not encounter this (IMHO, not quite obvious) behavior? Or are there other pitfalls? Is there any intelligible text about this mechanism?
Thank you )

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
Yudgin888, 2022-02-16
@Yudgin888

fastcgi_param PHP_ADMIN_VALUE is set for a process before its lifetime expires, and such a parameter cannot then be overridden via ini_set, only via another PHP_ADMIN_VALUE.
Description of these directives is here https://www.php.net/manual/en/configuration.changes.php
Answering the question: yes, you will not encounter such behavior. But you need to remember that this setting will also propagate to other server sections if they have the same php-fpm handler installed.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question