查閱不少資料,問題以下:php
mac系統升級到yosemite後,php也自動升級,運行phpcms時發現後臺驗證碼顯示不出來。很明顯,缺乏gd庫,須要從新編譯安裝php,其過程十分辛苦。git
但使用brew安裝比較方便。github
因此操做步驟以下:apache
一、安裝brew(已經安裝的略過)
二、安裝php5.6
三、安裝freetype,jpeg,libpng,gd,zlibruby
具體過程:bash
$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"複製代碼
這裏因爲網速緣由估計會比較慢
完成後,接下來自檢一下:curl
$ brew doctor Please note that these warnings are just used to help the Homebrew maintainers with debugging if you file an issue. If everything you use Homebrew for is working fine: please don't worry and just ignore them. Thanks! Warning: A newer Command Line Tools release is available. Update them from Software Update in the App Store.複製代碼
出現一些警告信息,其中也說明了若是brew運行正常就不用管它。CTRL+C退出,繼續往下ui
配置第三方源url
由於homebrew沒有自帶php的包,因此要添加新的源進來:spa
$ brew tap homebrew/dupes
$ brew tap homebrew/versions $ brew tap homebrew/homebrew-php複製代碼
install安裝
$ brew install php56複製代碼
安裝過程須要一段時間,等一下就能夠了。
安裝freetype,jpeg,libpng,gd,zlib
brew rm freetype jpeg libpng gd zlib brew install freetype jpeg libpng gd zlib
先刪除以前的再安裝新的複製代碼
而後建立連接
brew link --overwrite libpng freetype jpeg
#注意添加overwrite,不然可能會提示衝突 這裏可能提示目錄權限錯誤問題:
Error: Could not symlink include/libpng16/png.h 執行命令:
sudo chmod -R 777 /usr/local/include/libpng16
sudo chmod -R 777 /usr/local/include/freetype2複製代碼
配置apache支持新安裝的php
安裝的php在/usr/local/opt/php56目錄,apache這邊須要修改配置文件,加載進新安裝的php模塊。
$ LoadModule php5_module /usr/local/opt/php56/libexec/apache2/libphp5.so複製代碼
不要忘記從新啓動下apache
$ sudo apachectl restart複製代碼
重啓完成後,看看驗證碼是否顯示了