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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM