https://www.it610.com/article/1288159441018990592.htm
直接安装
sudo pecl install redis
sudo pecl install redis-3.2.9
源码安装
查看现有版本:http://pecl.php.net/package/redis
使用pecl下载安装
pecl dowload redis-3.2.9
sudo mv redis-3.2.9 /usr/local/
cd /usr/local/redis-3.2.9
phpize
./configure --with-php-config=/usr/local/php/bin/php-config #配置 (要找到php-config目录)
make && make install
make test
启动
make install
问题:
一、用pecl安装一直报这个错 checking for hash includes... configure: error: Cannot find php_hash.h
ERROR: `/private/tmp/pear/install/redis/configure --with-php-config=/usr/bin/php-config --enable-redis-igbinary=yes --enable-redis-lzf=yes --enable-redis-zstd=yes' failed
解决方式:直接到下载目录源码安装
cd /private/tmp/pear/install
sudo tar -zxvf redis-5.3.2.tgz
sudo mv redis-5.3.2 redis
cd redis
sudo phpize
sudo ./configure
sudo make && sudo make install
找到php.ini 写入内容
vim /usr/local/etc/php/7.4/php.ini
添加:extension=redis
再用php -m | grep redis
打印出redis 说明成功了