Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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' \

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.

share|improve this question

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.

share|improve this answer
up vote 1 down vote accepted

The issue was not that php wasn't including the additional .ini files in the end.

I recompiled php and noticed that the 'make install' command failed to finish. The error produced was:

apxs:Error: Activation failed for custom /etc/apache2/httpd.conf file..
apxs:Error: At least one `LoadModule' directive already has to exist..

As Apache ships with apache2.conf, which includes the module directives and httpd.conf, the httpd.conf is, in fact, empty.

Simply adding:

# Dummy LoadModule directive to aid module installations
# LoadModule dummy_module /usr/lib/apache2/modules/

to httpd.conf allows apxs to run without any errors and the complete php installation finishes successfully.

The PDO drivers were then available on the CLI as well as via Apache.

As radius suggested, in essence, I wasn't using a good binary. Thanks for your help.

share|improve this answer

I had the same problem. Simply check owner and permissions for every file in /etc/php5/conf.d/. It has to be owned by root and readable by any other user.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.