这个库比较好用:https://github.com/shivammathur/homebrew-php
旧⬇️
安装已经停止维护的源
https://github.com/eXolnet/homebrew-deprecated
brew tap exolnet/homebrew-deprecated
可先搜索
brew search php
安装
brew install php@5.6
解决报错
类库版本不兼容
dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.64.dylib
Referenced from: /usr/local/Cellar/php@5.6/5.6.40/bin/php
Reason: image not found
编辑php@5.6的ruby源文件添加补丁
/usr/local/Homebrew/Library/Taps/exolnet/homebrew-deprecated/Formula/php@5.6.rb
brew edit php@5.6
在45-48行添加以下内容
patch do
url "https://raw.githubusercontent.com/opencomputeproject/Rack-Manager/master/Contrib-Inspur/openbmc/meta-openembedded/meta-oe/recipes-devtools/php/php/0001-PHP-5.6-LibSSL-1.1-compatibility.patch"
sha256 "c9715b544ae249c0e76136dfadd9d282237233459694b9e75d0e3e094ab0c993"
end
通过源码构建
brew reinstall --build-from-source php@5.6
期间也许资源加载很慢,可以将ruby文件的加载源修改一个高效地址,图中是我修改的本地源
可参考:
https://github.com/eXolnet/homebrew-deprecated/issues/23#issuecomment-619976586
https://github.com/ningkexin/comment/issues/11