When I run PHP 8.1 from the command line (using a command line script such as #!/usr/local/bin/php81 -q for a script.cgi) it uses the correct INI and only the correct INI.
eg.
core(/temp): php81 -i | grep 'Configuration File'
Configuration File (php.ini) Path => /opt/cpanel/ea-php81/root/etc
Loaded Configuration File => /opt/cpanel/ea-php81/root/etc/php.ini
core(/temp): php81 -i | grep -i 'Additional'
Scan this dir for additional .ini files => /opt/cpanel/ea-php81/root/etc/php.d
Additional .ini files parsed => /opt/cpanel/ea-php81/root/etc/php.d/01-ioncube.ini,
Notice the "Scan this dir for additional .ini files" is only 8.1 which I want. It doesn't try to go all over the place looking for other .ini files.
Now I run this exact command line PHP script using shell_exec from a PHP 7.2 web page.
eg.
shell_exec('/path/script.cgi');
It will work, but imports the wrong PHP file now.
eg.
Configuration File (php.ini) Path => /opt/cpanel/ea-php81/root/etc
Loaded Configuration File => /opt/cpanel/ea-php81/root/etc/php.ini
Scan this dir for additional .ini files => /opt/cpanel/ea-php72/root/etc:/opt/cpanel/ea-php72/root/etc/php.d:.
Additional .ini files parsed => /opt/cpanel/ea-php72/root/etc/php.ini,
Why? What is telling the command line script script.cgi to all of a sudden try to load the ini for 7.2 when run under shell_exec? It runs perfeclty fine at the command line only.
eg.
core(/temp): php81 -i | grep 'Configuration File'
Configuration File (php.ini) Path => /opt/cpanel/ea-php81/root/etc
Loaded Configuration File => /opt/cpanel/ea-php81/root/etc/php.ini
core(/temp): php81 -i | grep -i 'Additional'
Scan this dir for additional .ini files => /opt/cpanel/ea-php81/root/etc/php.d
Additional .ini files parsed => /opt/cpanel/ea-php81/root/etc/php.d/01-ioncube.ini,
Notice the "Scan this dir for additional .ini files" is only 8.1 which I want. It doesn't try to go all over the place looking for other .ini files.
Now I run this exact command line PHP script using shell_exec from a PHP 7.2 web page.
eg.
shell_exec('/path/script.cgi');
It will work, but imports the wrong PHP file now.
eg.
Configuration File (php.ini) Path => /opt/cpanel/ea-php81/root/etc
Loaded Configuration File => /opt/cpanel/ea-php81/root/etc/php.ini
Scan this dir for additional .ini files => /opt/cpanel/ea-php72/root/etc:/opt/cpanel/ea-php72/root/etc/php.d:.
Additional .ini files parsed => /opt/cpanel/ea-php72/root/etc/php.ini,
Why? What is telling the command line script script.cgi to all of a sudden try to load the ini for 7.2 when run under shell_exec? It runs perfeclty fine at the command line only.