Russell Russell - 1 year ago 152
Apache Configuration Question

Different versions of PHP on the Server vs CLI

I am running a Mac, and unfortunately have the different versions of PHP running in the CLI and on Apache. I have searched and can find instances of this question before but have not been able find a reason this occurs or how to resolve the issue.

When I run phpinfo(); and load it in the browser I get the following:

Version 5.6.24

Loaded config file: /etc/php.ini

Server Path: /usr/bin:/bin:/usr/sbin:/sbin

But when I run php -v & php --ini in the command line, I get the following:

Version 5.6.0

Loaded config file: /usr/local/lib/php.ini

When I run 'whereis php' it shows /usr/bin/php and when I run 'which php' I get /usr/local/bin/php.

Can anyone explain why this has happened? And does anyone know how this can be resolved? I would like to, if possible, resolve the underlying issue rather than find a workaround. I'd also like to uninstall the version of PHP that is not being used.

Answer Source

Your path is set to the wrong/older version. Do a export PATH=/usr/local/php5/bin:$PATH

Restart the terminal and php -v

Alternatively have a look at Have a look at: Mac upgraded PHP to 5.6, but CLI php -v get 5.3.28? and follow @mark-reed comment on the @bing answer.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download