4

There are many questions like this, but I haven't found one that explains this behavior. I'll try to address things covered in similar questions as I go:

I installed php 5.3.28 from source and copied php.ini-production from the source to /usr/local/etc/php53/php.ini. I used the following configure options so that PHP would read that file.

# Rearranged for readability
Configure Command =>  './configure'  
                  '--with-config-file-path=/usr/local/etc/php53' 
                  '--with-config-file-scan-dir=/usr/local/etc/php53/conf.d'
                  '--prefix=/usr/local' 
                  '--enable-debug' '--enable-mbstring' '--enable-soap' '--enable-zip' '--with-bz2' '--with-curl' '--with-gettext' '--with-mcrypt' '--with-mhash' '--with-mysql' '--with-openssl' '--with-pdo-mysql' '--with-pspell' '--with-readline' '--with-tidy' '--with-xsl'

Well, PHP doesn't read that file.

$ php -i | grep Configuration' File'
Configuration File (php.ini) Path => /usr/local/etc/php53
Loaded Configuration File => (none)
$ php --ini
Configuration File (php.ini) Path: /usr/local/lib
Loaded Configuration File:         (none)
Scan for additional .ini files in: (none)
Additional .ini files parsed:      (none)

How can it be that php -i and php --ini have different output for Configuration File (php.ini) Path?

(Some answers/comments to similar questions want to know which php command is in use. It's important to note that this issue is with php on the commandline, so the php above is the only one. Whether or not Apache is using a different php is not relevant in this case.)

I do not have any php environment variables set:

$ env | grep PHP
$ export | grep -iF php
$ set | grep -iF php

There is no output for any of the above.

Finally, I can force php to do what I want via a commandline flag (evidence that php can read and parse the file)

$ php -nc /usr/local/etc/php53/php.ini -i | grep -F Configuration' Fi'
Configuration File (php.ini) Path => /usr/local/etc/php53
Loaded Configuration File => /usr/local/etc/php53/php.ini
$ php -nc /usr/local/etc/php53/php.ini --ini
Configuration File (php.ini) Path: /usr/local/lib
Loaded Configuration File:         /usr/local/etc/php53/php.ini
Scan for additional .ini files in: (none)
Additional .ini files parsed:      (none)

But why does it not load the file I specified to configure when I don't give it any flags on the commandline?

Community
  • 1
  • 1
kojiro
  • 74,557
  • 19
  • 143
  • 201
  • possible duplicate of [PHP Command Line php.ini path error](http://stackoverflow.com/questions/5132978/php-command-line-php-ini-path-error) – Paul Sweatte Dec 12 '14 at 01:54
  • It's not a dupe. That question addresses neither the discrepancy between --ini and -i, nor the explicit build time configuration option. Furthermore, the configuration file path output by -i here is correct. In the other question it's not. – kojiro Dec 12 '14 at 02:47

0 Answers0