一定不要忘记前面加上 sudo
直接运行命令 sudo pecl install mongodb
sudo pecl install mongodb
sudo pecl install memcached
sudo pecl install redis
为什么是这条命令(以安装mongodb扩展为例)
进入pecl官网
搜索相应的扩展
可能出现的问题
- 安装redis出现以下错误:
pecl/redis is already installed and is the same as the released version 5.3.7
install failed
解决办法:
# 先卸载,再安装
sudo pecl uninstall redis
sudo pecl install redis
- 安装memcache扩展出现的错误
- 错误1
checking for the location of zlib... configure: error: memcache support requires ZLIB. Use --with-zlib-dir=<DIR> to specify prefix where ZLIB include and library are located
ERROR: `/private/tmp/pear/install/memcache/configure --with-php-config=/usr/local/opt/php@8.0/bin/php-config --enable-memcache-session=yes' failed
解决办法 :缺什么就安装什么
brew install zlib
- 错误2
checking for libmemcached location... configure: error: memcached support requires libmemcached. Use --with-libmemcached-dir=<DIR> to specify the prefix where libmemcached headers and library are located
ERROR: `/private/tmp/pear/install/memcached/configure --with-php-config=/usr/local/opt/php@8.0/bin/php-config --with-libmemcached-dir=no --with-zlib-dir=no --with-system-fastlz=no --enable-memcached-igbinary=no --enable-memcached-msgpack=no --enable-memcached-json=no --enable-memcached-protocol=no --enable-memcached-sasl=yes --enable-memcached-session=yes' failed
解决办法
brew install libmemcached