我一直在mac上用brew管理软件,当我想安装php扩展时发现无论如何也安装不上,然后反复查找才知道
Homebrew/php自来水在2018年3月底被弃用,并将所有PHP公式转移到Homebrew/core,旧的brew tap homebrew/dupes、brew tap homebrew/versions、brew tap homebrew/homebrew-php都会报以下错误
Warning: homebrew/dupes was deprecated. This tap is now empty as all its formulae were migrated.
看到这条消息心直接凉半截,在也不能用brew install php72-redis愉快的玩耍啦,无奈只好另谋其它办法。
还好有位大神给出的解决办法如下:
redis的安装
參考 https://github.com/phan/phan/wiki/Getting-Started#from-homebrew
因 homebrew/php 已在 1.5 版併入 homebrew/core
所以须先移除旧版,然后安装新版,再用pecl安装:
brew update; # updates local brew meta data # removes old homebrew php TAP, now php is in homebrew core brew untap homebrew/php; brew uninstall php; # or brew uninstall php72 if you had that before brew upgrade; # make sure all the other libs are up to date brew cleanup; # cleanup old files brew prune; # cleanup old symlinks brew install autoconf; # Required by pecl brew install php; pecl install redis;
经过我的实践此方法是可行的,我是直接用了最后一个命令安装成功的,大家可以根据自己的情况执行。
memcache的安装
php7安装http://pecl.php.net/package/memcache下的任何一款扩展都会报错的,所以大家就不要尝试了。
这里推荐:Github的pecl-memcache分支版本
下载地址:https://github.com/websupport-sk/pecl-memcache/archive/php7.zip
1、就是我们熟悉的编译安装
unzip pecl-memcache-php7.zip cd pecl-memcache-php7 /usr/local/php/bin/phpize ./configure --with-php-config=/usr/local/php/bin/php-config make && make install
2、修改php.ini,加载memcache
extension_dir = "/usr/local/php70/lib/php/extensions/no-debug-non-zts-20151012/" extension = "memcache.so"
最后重启PHP,大家试试是不是大功告成啦。