First time to post here and I'm a PHP newbie (please go easy on me). I already have Apache/2.4.9 (Unix) installed on my Mac running on OS X 10.10 Yosemite. I can also successfully run websites on my local machine. However, when I output phpinfo();
in a browser, it tells me that my configuration file is not loaded:
Configuration File (php.ini) Path | /etc
Loaded Configuration File | (none)
Note that I already have php.ini
in /etc
.
Using terminal, I ran the following command: $ php -i | grep 'Configuration File'
and I got this:
Configuration File (php.ini) Path => /etc Loaded Configuration File => /etc/php.ini
Why are phpinfo();
and php -i
showing two different things? Please help! Thank you!
When you invoke the php
command in the terminal, you will be getting the CLI version of PHP. You can confirm this by looking for the Server API
value in the output of php -i
:
$ php -i | grep "Server API"
Server API => Command Line Interface
Whereas your Apache server is likely using the Apache 2.0 Handler
PHP SAPI, which will probably have a different configuration.
Where the default location for php.ini files is is platform-dependent. Still the phpinfo output in the Apache version of PHP might reveal the search paths (i.e. where to put your .ini file). The values to look for in the output of phpinfo should be Configuration File (php.ini) Path
and Scan this dir for additional .ini files
.