mac下多个php版本切换(可操作版)
mac下多个php版本切换(可操作版)
参考了多个文章,并且进行测试实践,总结了如下正确的操作方式
实践
适用版本:
OS X Version: 10.12.3 (16D32) -------- Homebrew 1.3.2 Homebrew/homebrew-core (git revision aeab0; last commit 2017-09-14) -------- PHP Version in use: php71 56
并且,前提你已经按照php56了
1.brew update
需要先更新brew的软件仓库目录
2.brew upgrade
根据之前的update更新的软件仓库目录,用upgrade来更新所有软件和相关依赖,为了保证安装软件的正确
备注:
用doctor进行打印出错的详细地方,安装顺利的话,不需要使用
brew doctor
3.brew install php71
需要先安装这个php仓库
brew tap josegonzalez/homebrew-php
然后安装php71
brew install php71
需要注意的是,这里需要先解除homebrew与php56的关联,然后再安装php71
brew unlink php56
4.安装php-version
安装php-version
brew install php-version
设置php-version的初始化
source $(brew --prefix php-version)/php-version.sh
这样就可以使用多个版本了
php-version * 5.6.30 7.1.8 ➜ ~ php -version PHP 5.6.30 (cli) (built: Sep 15 2017 14:11:24) (DEBUG) Copyright (c) 1997-2016 The PHP Group Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies ➜ ~ php -version PHP 7.1.8 (cli) (built: Sep 15 2017 14:26:34) ( NTS ) Copyright (c) 1997-2017 The PHP Group Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies ➜ ~ php-version 5.6.30 * 7.1.8
遇到问题
报错:
dyld: Library not loaded: /usr/local/opt/libpng/lib/libpng16.16.dylib Referenced from: /usr/local/bin/php Reason: Incompatible library version: php requires version 45.0.0 or later, but libpng16.16.dylib provides version 38.0.0 Abort trap: 6
dyld: Library not loaded: /usr/local/opt/libpng/lib/libpng16.16.dylib Referenced from: /usr/local/Cellar/php70/7.0.22_14/bin/php Reason: Incompatible library version: php requires version 48.0.0 or later, but libpng16.16.dylib provides version 45.0.0
其实报错都差不多,都是说libpng版本有问题,解决的办法有2个:
1.更新libpng,如果解决不了,就跳到2选项
brew upgrade libpng
2.不要使用php70,使用php71
7.0怎么测试都不行,切换7.1就好了
参考文章如下:
https://code-ken.github.io/20...
https://github.com/Homebrew/h...
https://github.com/Homebrew/b...
https://github.com/wilmoore/p...
相关推荐
zyyjay 2020-11-09
xuebingnan 2020-11-05
samtrue 2020-11-22
stefan0 2020-11-22
yifangs 2020-10-13
songshijiazuaa 2020-09-24
hebiwtc 2020-09-18
天步 2020-09-17
83911535 2020-11-13
whatsyourname 2020-11-13
zhouyuqi 2020-11-10
Noneyes 2020-11-10
mathchao 2020-10-28
王志龙 2020-10-28
wwwsurfphpseocom 2020-10-28
diskingchuan 2020-10-23
savorTheFlavor 2020-10-23