Mac 下更新自带的PHP版本5.3到7.0
下载和安装PHP 7.0打开终端并运行如下的命令:
curl -s http://php-osx.liip.ch/install.sh | bash -s 7.0
回车后,你会看到一个EI Capitan下的警告:
Detected OS X El Capitan 10.11. As this is quite new, there may be issues still. Your mileage may vary.
不用管这个警告,等待下载安装完毕即可。
配置路径
安装完毕如果在终端里运行PHP -v命令,还是会显示mac自带的旧版本。因此,我们还需要配置一下路径。
在命令行中输入如下命令:
sudo vim ~/.bash_profile
然后,在文件的最后加上:
export PATH=/usr/local/php5-7.0.7-20160526-160257/bin:$PATH;
注意:我这里是以安装的PHP7.0的路径来配置的,你需要进到/usr/local中查看你所安装的PHP的路径。
最后,运行命令:
source ~/.bash_profile
配置完成,再试试php -v显示的就是最新安装的PHP版本了。
PHP 7.0.24 (cli) (built: Oct 2 2017 09:17:48) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
with Zend OPcache v7.0.24, Copyright (c) 1999-2017, by Zend Technologies
with Xdebug v2.5.3, Copyright (c) 2002-2017, by Derick Rethans
如果继续想还原php版本,即把~/.bash_profile文件中注释掉
#export PATH=/usr/local/php5-7.0.7-20160526-160257/bin:$PATH;
然后执行source ~/.bash_profile
此时在执行php -v看下
PHP 5.6.30 (cli) (built: Feb 7 2017 16:18:37)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
热门日志
分类
- Django(4)
- ssdb(1)
- Mac(7)
- C(1)
- memcache(1)
- Python(32)
- Vim(8)
- sed(2)
- ansible(3)
- awk(4)
- shell(3)
- about(1)
- git(9)
- bat(4)
- svn(0)
- docker(1)
- Tornado(1)
- go(2)
- 架构(18)
- Vue(1)
- game(2)
- Html(6)
- Java(8)
- Mysql(37)
- Ajax(2)
- Jsp(1)
- Struts(8)
- Linux(72)
- JavaScript(39)
- Staruml(0)
- Mouth(1)
- Php(102)
- Windows(8)
- Message(48)
- Lua(10)
- Compute(1)
- Redis(7)
- Nginx(12)
- Jquery(1)
- Apache(1)
- cocos2d-x(8)