macOS 中使用 phpize 动态添加 PHP 扩展的错误解决方法

使用 phpize 动态添加 PHP 扩展是开发中常常须要作的事情,可是在 macOS 中,首次使用该功能必然会碰到一些错误,本文列出了这些错误的解决方法。php

问题一:

执行 phpize 报错以下:html

$ 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:

解决方法:git

$ ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include /usr/include

PS:若是 sudo 受权后仍提示没有操做权限,请参考文章macOS 中的 Rootless 机制github

问题二:

执行 phpize 报错以下:ruby

$ phpize 
Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONF environment variable. Then, rerun this script.

解决方法:

先安装 Homebrew :app

$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

而后安装 autoconf :less

$ brew install autoconf

PS:Homebrew 的强大谁用谁知道。关于什么是 Homebrew,以及 Homebrew 的使用,请点击 Homebrew传送门。不建议手动安装 autoconf 软件包,由于依赖包太多~~curl


本文首发于马燕龙我的博客,欢迎分享,转载请标明出处。
马燕龙我的博客:http://www.mayanlong.com
马燕龙我的微博:http://weibo.com/imayanlong
马燕龙Github主页:https://github.com/yanlongmathis

相关文章
相关标签/搜索