Mac 将 PHP 升级到 5.6,但是 CLI php -v 得到 5.3.28?
我已经在我的机器上安装了 MAMP(随 PHP 5.5 提供).并且 localhost 指向/Applications/MAMP/htdocs.当我尝试在终端中使用 composer 在 htdocs 中安装依赖项时,就会出现问题.Composer 抱怨 PHP 必须是 5.4 或以上.
I have installed MAMP (comes with PHP 5.5) on my machine. And localhost pointed to /Applications/MAMP/htdocs. The problem happened when I was trying to use composer in terminal to install dependencies in htdocs. Composer complained that PHP must be 5.4 or above.
我猜它抱怨 PHP 是 OSX 自带的.所以我通过
I guess it complained about PHP comes with OSX. So I have upgraded PHP to 5.6 by
curl -s http://php-osx.liip.ch/install.sh | bash -s 5.6
但是当我这样做时
$ php -v
我还是得到了
PHP 5.3.28 (cli) (built: Aug 29 2014 18:52:17)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2013 Zend Technologies
Composer 还在抱怨……
And Composer is still complaining...
这是为什么呢?以及如何解决这个问题?
Why is that? And how to fix this?
推荐答案
如果你已经使用 curl 升级,复制 &粘贴以下代码行并回车.
If you have upgraded using curl, copy & paste the following line of code and press enter.
$ export PATH=/usr/local/php5/bin:$PATH
$ export PATH=/usr/local/php5/bin:$PATH
现在,输入$ php -v
Now, type $ php -v
如果操作正确,它应该显示以下内容
If done correctly, it should show the following
PHP 5.6.23 (cli)(构建时间:2016 年 6 月 26 日 13:17:47)版权所有 (c) 1997-2016 PHP 集团Zend Engine v2.6.0,版权所有 (c) 1998-2016 Zend TechnologiesZend OPcache v7.0.6-dev,版权所有 (c) 1999-2016,Zend Technologies使用 Xdebug v2.2.5,版权所有 (c) 2002-2014,由 Derick Rethans 提供
PHP 5.6.23 (cli) (built: Jun 26 2016 13:17:47) Copyright (c) 1997-2016 The PHP Group Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies with Xdebug v2.2.5, Copyright (c) 2002-2014, by Derick Rethans
相关文章