修复macOS Mojave上缺少的标头编译 - phpize

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

但是我发现我在这没有这个文件。就到墙外找了资料,特此记录下来。

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值