10

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?

2
  • Where did you install the updated PHP and what is your current $PATH? (type echo $PATH in Terminal). It sounds like the $PATH isn't set up to find the new version of PHP. – sdmeyers Feb 12 '15 at 19:32
  • I installed to "/usr/local". When I checked the path with "echo $PATH" I saw "/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Applications/Server.app/Contents/ServerRoot/usr/bin:/Applications/Server.app/Contents/ServerRoot/usr/sbin". I deleted the Server App recently. Should I export the path? – AndrewMRiv Feb 12 '15 at 20:12
1

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.

3
  • 1
    Well, I upgrade to PHP 7 in /usr/local/bin/ but my version remains in 5.6.24. The installer created a php5 alias and I created a php alias manually. But both <?php phpinfo();?> and php -v tells me I am using the old one. And I tried export PATH=/usr/local/bin/php5-7.0.11-20160923-203451:"${PATH}" too. – James Wayne Sep 28 '16 at 21:29
  • @JamesWayne Try export PATH=/usr/local/php5/bin:$PATH – bart Jan 24 '18 at 20:26
  • Whoa there... First, that path statement is all wrong... where is the newest version of PHP installed (how did you install it)? Knowing this, I can help you on the command line (assuming it's all installed correctly). Second, after updating PHP did you reconfigure your web server to use the new version of PHP? – sdmeyers Feb 7 '18 at 18:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .