目录
brew install redis
% brew services start redis
==> Successfully started `redis` (label: homebrew.mxcl.redis)
% redis-cli
127.0.0.1:6379> set name 123
OK
127.0.0.1:6379> get name
"123"
127.0.0.1:6379>
我用的是php7.4对应的redis扩展是5.2.1
https://github.com/phpredis/phpredis/archive/refs/tags/5.2.1.tar.gz
% sudo wget -c https://github.com/phpredis/phpredis/archive/refs/tags/5.2.1.tar.gz
如果没有wget,安装一下
brew install wget
解压
% sudo tar -zxvf 5.2.1.tar.gz
% cd phpredis-5.2.1
% sudo /opt/homebrew/Cellar/php@7.4/7.4.25/bin/phpize
Password:
Configuring for:
PHP Api Version: 20190902
Zend Module Api No: 20190902
Zend Extension Api No: 320190902
% sudo ./configure --with-php-config=/opt/homebrew/Cellar/php@7.4/7.4.25/bin/php-config
% sudo make && sudo make install
... #此处省略
Build complete.
Don't forget to run 'make test'.
Installing shared extensions: /opt/homebrew/Cellar/php@7.4/7.4.25/pecl/20190902/
vim /opt/homebrew/etc/php/7.4/php.ini
添加
extension=redis.so
% brew services restart php@7.4
Stopping `php@7.4`... (might take a while)
==> Successfully stopped `php@7.4` (label: homebrew.mxcl.php@7.4)
==> Successfully started `php@7.4` (label: homebrew.mxcl.php@7.4)
% php -m | grep redis
redis
成功!