參考了多個文章,而且進行測試實踐,總結了以下正確的操做方式php
適用版本:git
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了github
須要先更新brew的軟件倉庫目錄php7
根據以前的update更新的軟件倉庫目錄,用upgrade來更新全部軟件和相關依賴,爲了保證安裝軟件的正確ide
備註:
用doctor進行打印出錯的詳細地方,安裝順利的話,不須要使用測試
brew doctor
須要先安裝這個php倉庫ui
brew tap josegonzalez/homebrew-php
而後安裝php71code
brew install php71
須要注意的是,這裏須要先解除homebrew與php56的關聯,而後再安裝php71homebrew
brew unlink php56
安裝php-versionget
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...