shell_exec from PHP loads wrong ini file?
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.
-
Hey there! Unless I'm misunderstanding, this sounds like normal behavior to me. Since the account has PHP 7.2 as the default, it will also use that configuration file as well. Is that not what's happening? 0 -
Thanks for the additional details. I'm not familiar with how shell_exec interprets things, so I think this is worthy of a ticket. Could you get one submitted and then post the number here? 0
Please sign in to leave a comment.
Comments
3 comments