macOS 中使用 phpize 動態添加 PHP 擴展的錯誤解決方法

使用 phpize 動態添加 PHP 擴展是開發中經常需要做的事情,但是在 macOS 中,首次使用該功能必然會碰到一些錯誤,本文列出了這些錯誤的解決方法。

問題一:

執行 phpize 報錯如下:

$ 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 授權后仍提示沒有操作權限,請參考文章 macOS 中的 Rootless 機制

問題二:

執行 phpize 報錯如下:

$ 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 的強大誰用誰知道。關于什么是 Homebrew,以及 Homebrew 的使用,請點擊 Homebrew傳送門。不建議手動安裝 autoconf 軟件包,因為依賴包太多~~


本文首發于馬燕龍個人博客,歡迎分享,轉載請標明出處。
馬燕龍個人博客:http://www.mayanlong.com
馬燕龍個人微博:http://weibo.com/imayanlong
馬燕龍Github主頁:https://github.com/yanlongma

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容