再论MAC安装PHP扩展报错:grep: /usr/include/php/main/php.h: No such file or directory

开发时,偶然需要安装php额外扩展,于是使用phpize,结果error,执行phpize -v一看,额>_<

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:  

在mac高版本/usr/include不存在了,所以这里报错。于是在网上搜索解决方案,于是漫长的“黑科技”操作开始了,就是用各种方法生成这个目录。而遗憾的是:我的mac版本是当前最新的11.2.3版本,所有这些骚操作全部无效,顿时汗了。

苹果系统干掉/usr/include肯定是有原因的,肯定存在另外一种方法解决这个问题。为什么要花这么多心思,这么头铁地跟系统较劲,一定要创建出这个/usr/includ?

本人使用的是php7.3,通过brew安装。仔细观察命令行,直接调用phpize是使用的/usr/bin中的phpize,而通过brew安装的php的命令位于/usr/local/Cellar/php@7.3/7.3.27/bin中,那么尝试改用它的命令执行:/usr/local/Cellar/php@7.3/7.3.27/bin/phpize -v

Configuring for:
PHP Api Version:         20180731
Zend Module Api No:      20180731
Zend Extension Api No:   320180731

运行通过,看来,MAC安装扩展需要指明php安装的真实位置,使用默认的很可能就会因为没有/usr/include目录而报错。那么对应mac,安装扩展的正确命令应该如下(以brew安装的php@7.3为例):

/usr/local/Cellar/php@7.3/7.3.27/bin/phpize
./configure --with-php-config=/usr/local/Cellar/php@7.3/7.3.27/bin/php-config
make
make install

完成后,记得php.ini加入扩展配置(extension=xxxx.so),并重启php-fpm让扩展生效。

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值