解决php安装扩展 configure: error: C compiler cannot create executables

问题描述:

最近升级了mac系统,新安装了php74版本,在安装redis扩展的时候,提示错误如下:
checking for pkg-config... /usr/local/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for cc... cc
checking whether the C compiler works... no

configure: error: in `/private/tmp/pear/temp/pear-build-liangtengJrbXtT/redis-5.3.7':
configure: error: C compiler cannot create executables
See `config.log' for more details
ERROR: `/private/tmp/pear/temp/redis/configure --with-php-config=/usr/local/opt/php@7.4/bin/php-config --enable-redis-igbinary=no --enable-redis-lzf=no --enable-redis-zstd=no' failed

百度了好久,没有找到解决方案。
不论是使用 pecl安装,还是源码编译安装,都绕不开这个问题,没办法,只能解决这个问题:
查看上面的报错信息,会发现有一行 checking whether the C compiler works… no, 我假设是gcc的问题,重试安装gcc,结果仍然报错,但是有提示安装 xcode,那就试一下:

安装 xcode 命令:
	xcode-select --install

安装xcode完成后,再次使用 pecl install redis
redis安装成功,extension=redis.so 也被自动的写入到了php.ini,接下来只需要重启php就ok了

pecl 需要在PHP安装目录的bin目录下执行
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值