使用 phpize 動態(tài)添加 PHP 擴(kuò)展是開發(fā)中經(jīng)常需要做的事情恋追,但是在 macOS 中,首次使用該功能必然會碰到一些錯誤喊崖,本文列出了這些錯誤的解決方法饲化。
問題一:
執(zhí)行 phpize 報(bào)錯如下:
$ phpize
grep: /usr/include/php/main/php.h: No such file or directory
grep: /usr/include/php/Zend/zend_modules.h: No such file or directory
grep: /usr/include/php/Zend/zend_extensions.h: No such file or directory
Configuring for:
PHP Api Version:
Zend Module Api No:
Zend Extension Api No:
解決方法:
$ ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include /usr/include
PS:如果 sudo 授權(quán)后仍提示沒有操作權(quán)限,請參考文章 macOS 中的 Rootless 機(jī)制 金蜀。
問題二:
執(zhí)行 phpize 報(bào)錯如下:
$ phpize
Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONF environment variable. Then, rerun this script.
解決方法:
先安裝 Homebrew :
$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
然后安裝 autoconf :
$ brew install autoconf
PS:Homebrew 的強(qiáng)大誰用誰知道刷后。關(guān)于什么是 Homebrew,以及 Homebrew 的使用渊抄,請點(diǎn)擊 Homebrew傳送門尝胆。不建議手動安裝 autoconf 軟件包,因?yàn)橐蕾嚢鄜~
本文首發(fā)于馬燕龍個(gè)人博客护桦,歡迎分享含衔,轉(zhuǎn)載請標(biāo)明出處。
馬燕龍個(gè)人博客:http://www.mayanlong.com
馬燕龍個(gè)人微博:http://weibo.com/imayanlong
馬燕龍Github主頁:https://github.com/yanlongma