The php that run on the webserver and the CLI version is not using the same php.ini file. If I do a command php --ini
, it show this
Configuration File (php.ini) Path: C:\Windows
Loaded Configuration File: C:\wamp\bin\php\php5.3.8\php.ini
Scan for additional .ini files in: (none)
Additional .ini files parsed: (none)
while my web version uses the php.ini in C:\wamp\bin\apache\Apache2.2.21\bin\php.ini
. This is probably very common for people using wamp.
How do I change the Loaded Configuration File to read from C:\wamp\bin\apache\Apache2.2.21\bin\php.ini
so I don't have to maintain 2 different php.ini versions?
Per http://php.net/configuration.file:
For CLI, your best bet is probably either to set the
$PHPRC
environment variable for the account that will be executing scripts, or recompile PHP with a different--with-config-file-path
configuration setting.You can also override the php.ini search dir on a per-execution basis by specifying the
-c
option when invoking PHP:try running the
phpinfo()
function on both sideWebserver and CLI and find out the exact location of your
php.ini
file for both sideand maintain those files only
By specifying environment variable PHPRC to point to the same php.ini as the one Apache uses worked for me on Ubuntu
Or put it in the $HOME/.bashrc to import every time cli is started
I have spent about 3 hours trying to do exactly what your question asks. Couldn't do it. I gave up and copied that php.ini to C:\Windows and changed my ENV variable "PHPRC" to C:\Windows (and in httpd.conf). That way both my CLI php and Apach php e are using the same file. I could not get "php -m" to display the modules I had loaded in my php.ini for the life of me until I made this change...