先前参考 如何 实现PHP多版本的 共存 和 切换? 实现了Linux(Ubuntu/CentOS)系统下,PHP多版本的切换,但是在 Mac OS 下,由于用户权限控制的比较严格,文章里提到的脚本运行失败(没达到预期效果)。后面采用了其他方式实现了 通过执行脚本自由切换PHP版本:
/Users/jianbao/.bash_profile_56
/Users/jianbao/.bash_profile_70
.bash_profile_56 文件内容为:
alias ll=‘ls -alF‘ alias la=‘ls -A‘ alias l=‘ls -CF‘ export GOROOT=/usr/local/go export GOPATH=/Users/jianbao/GoProjects/go-study export PHP=/usr/local/php/php-5.6 export PATH=$GOROOT/bin:$GOPATH/bin:$PHP/bin:$PHP/sbin:/usr/local/nginx/sbin:/usr/local/mysql:/usr/local/Cellar/subversion/1.9.4/bin:$PATH
.bash_profile_70 文件内容为:
alias ll=‘ls -alF‘ alias la=‘ls -A‘ alias l=‘ls -CF‘ export GOROOT=/usr/local/go export GOPATH=/Users/jianbao/GoProjects/go-study export PHP=/usr/local/php/php-7.0 export PATH=$GOROOT/bin:$GOPATH/bin:$PHP/bin:$PHP/sbin:/usr/local/nginx/sbin:/usr/local/mysql:/usr/local/Cellar/subversion/1.9.4/bin:$PATH
/Users/jianbao/1/stop.sh
/Users/jianbao/1/start56.sh
/Users/jianbao/1/start70.sh
stop.sh 文件内容为:
sudo /usr/local/mysql/mysql stop sudo /usr/local/nginx/sbin/nginx -s stop sudo killall php-fpm
start56.sh 文件内容为:
source /Users/jianbao/1/stop.sh cat /Users/jianbao/.bash_profile_56 > /Users/jianbao/.bash_profile source /Users/jianbao/.bash_profile sudo /usr/local/mysql/mysql start sudo /usr/local/nginx/sbin/nginx sudo /usr/local/php/php-5.6/sbin/php-fpm -D
start70.sh 文件内容为:
source /Users/jianbao/1/stop.sh cat /Users/jianbao/.bash_profile_70 > /Users/jianbao/.bash_profile source /Users/jianbao/.bash_profile sudo /usr/local/mysql/mysql start sudo /usr/local/nginx/sbin/nginx sudo /usr/local/php/php-7.0/sbin/php-fpm -D
切换到 PHP-5.6,执行一下 ./start56.sh;
切换到 PHP-7.0,执行一下 ./start70.sh;
大功告成!
Mac Pro 实现 PHP-5.6 与 PHP-7.0 等多版本切换
原文:http://www.cnblogs.com/52php/p/6128031.html