MacOS – PHP version shown in command line differs from phpinfo(); in localhost:8000

macosPHP

I started my OS X PHP test server by typing

php -S localhost:8000

I updated my PHP on OS X to 5.6 and when I check the version through the command line by typing:

php -v

It tells me that I have "PHP 5.6.5"

When I start my PHP test server and look at the index.php file that has the phpinfo(); function, it tells me that I still have version 5.5.14 that comes with OS X.

What can I do to get my PHP version on localhost:8000 to reflect that change?

Best Answer

The new version of PHP needs to be in your $PATH and the path to the new version of php needs to be listed before /usr/bin. If the new version of php (the executable) is installed in /usr/local/bin/ you should be in good shape, otherwise you need to either link the new php executable there (ln -s /path/to/newphp /usr/local/bin/php) or add it's location to your $PATH (export PATH=/path/to/newphp:"${PATH}") (<- add this to your ~/.bash_profile).

One other possibility to check... is the new version of php named php? It's possible that it will be named something like php5 or some such thing. If so you'll need to create a a link or use that name on the command line.