Php cli additional .ini files not loaded

command-line-interfaceconfigurationPHP

I have compiled PHP 5.3 and everything seems to be working correctly except when running PHP from the command line.

When I run:

# php --ini

it produces this output:

Configuration File (php.ini) Path: /etc/php5/apache2
Loaded Configuration File:         /etc/php5/apache2/php.ini
Scan for additional .ini files in: (none)
Additional .ini files parsed:      (none)

When I create a page and output phpinfo(); I get this output:

Configuration File (php.ini) Path: /etc/php5/apache2
Loaded Configuration File:         /etc/php5/apache2/php.ini
Scan for additional .ini files in: /etc/php5/apache2/conf.d
Additional .ini files parsed:      /etc/php5/apache2/conf.d/curl.ini, /etc/php5/apache2/conf.d/gd.ini, /etc/php5/apache2/conf.d/imagick.ini, /etc/php5/apache2/conf.d/memcache.ini, /etc/php5/apache2/conf.d/mhash.ini, /etc/php5/apache2/conf.d/ming.ini, /etc/php5/apache2/conf.d/mysql.ini, /etc/php5/apache2/conf.d/mysqli.ini, /etc/php5/apache2/conf.d/pdo.ini, /etc/php5/apache2/conf.d/pdo_mysql.ini, /etc/php5/apache2/conf.d/pdo_sqlite.ini, /etc/php5/apache2/conf.d/pspell.ini, /etc/php5/apache2/conf.d/recode.ini, /etc/php5/apache2/conf.d/snmp.ini, /etc/php5/apache2/conf.d/sqlite.ini, /etc/php5/apache2/conf.d/tidy.ini, /etc/php5/apache2/conf.d/xmlrpc.ini, /etc/php5/apache2/conf.d/xsl.ini 

I cannot figure out why the additional .ini files are loaded when php is executed via apache and not when using the CLI. Does anyone have any ideas?

Here is the stripped down configuration that I used to compile PHP:

'./configure' \
'--prefix=/usr' \
'--with-config-file-path=/etc/php5/apache2' \
'--with-config-file-scan-dir=/etc/php5/apache2/conf.d'

I require the PDO mysql driver to be loaded for something I am running on the command line and I am guessing this is the root of the problem.

Any suggestions would be kindly received.

Best Answer

I don't know why config-file-scan-dir is not used when php run in cli (are you sure that the binary you load is the good one ? I mean the one you rebuild).
But you can use php -c /etc/php5/apache2/conf.d or set PHP_INI_SCAN_DIR to /etc/php5/apache2/conf.d as a workaround.