问题描述:
最近升级了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目录下执行