5

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.

1
  • I have opposite problem ... I want my apache php.ini to load addition configs ...any idea how to do it?
    – user269867
    Apr 27, 2017 at 22:15

3 Answers 3

2

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.

1

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/mod_dummy.so

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.

1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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