Mac Book上切换PHP版本

明确2个路径

Mac上自代PHP路径(php版本为7)

/usr/bin

我们自己安装的php版本位置(php版本为5)

/usr/local/php5

添加2个环境变量

vim ~./bash_profile

最后两行添加2行,如下

#export PATH=/usr/bin/
export PATH=/usr/local/php5/bin:/usr/local/php5/sbin:$PATH

注意:#是注释,注释就是让本行不生效,我现在要使用php5版本

刷新环境变量

source ~/.bash_profile

查看当前php版本

php -v

命令执行结果:

PHP 5.6.36 (cli) (built: Jul  3 2018 12:32:05) 
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.5.3, Copyright (c) 2002-2017, by Derick Rethans

评论

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×