mac 安装php扩展,用到phpize命令,提示
deMacBook-Pro:memcached-3.1.5 $ 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:
Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONF environment variable. Then, rerun this script.
这是缺少 PHP 的 header 头文件,再一看/usr/include 文件夹根本不存在
先确认 Xcode command line tools 没有安装完全
deMacBook-Pro:CommandLineTools $ sudo xcode-select --install
xcode-select: error: command line tools are already installed, use "Software Update" to install updates
提示这个说明已经安装,如未安装的会提示安装,下一步就行
执行下列命令安装 header 头文件 SDK
$ cd /Library/Developer/CommandLineTools/Packages/
$ open macOS_SDK_headers_for_macOS_10.14.pkg
注意:这里可能不存在pkg(被坑了好久) ,不存在需要下载 pkg文件
(找到资料说: 似乎最新版本的Xcode已删除了macOS_SDK_headers_for_macOS_10.14.pkg文件。)
$ sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /
再一看/usr/include 文件夹 ,存在就可以正常使用
使用phpize 如果报下列错误
HXdeMacBook-Pro:memcached-3.1.5 hx$ sudo phpize
Password:
Configuring for:
PHP Api Version: 20160303
Zend Module Api No: 20160303
Zend Extension Api No: 320160303
Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONF environment variable. Then, rerun this script.
安装 brew install autoconf
使用./configure 如果报下面错误,运行 brew instal pkg-config 安装再重试
$ ./configure --prefix=/usr/bin/php-config
.......
checking whether to use system FastLZ library... no
checking for ZLIB... yes, shared
checking for pkg-config... no
pkg-config not found
configure: error: Please reinstall the pkg-config distribution
注:刚重装系统,重新搭建php-nginx-mysql环境,卡在php安装扩展这,网上找了很多,都是直接运行
$ cd /Library/Developer/CommandLineTools/Packages/ $ open macOS_SDK_headers_for_macOS_10.14.pkg
但是我发现我在这没有这个文件。就到墙外找了资料,特此记录下来。