Mac M1 安装Redis,安装phpredis。php5.6版本。
安装
brew install redis
% brew install redis
==> Downloading https://mirrors.cloud.tencent.com/homebrew-bottles/bottles/redis-6.2.4.arm64_big_sur
######################################################################## 100.0%
==> Pouring redis-6.2.4.arm64_big_sur.bottle.tar.gz
==> Caveats
To have launchd start redis now and restart at login:
brew services start redis
Or, if you don't want/need a background service you can just run:
redis-server /opt/homebrew/etc/redis.conf
==> Summary
🍺 /opt/homebrew/Cellar/redis/6.2.4: 13 files, 2MB
启动服务
% brew services start redis
==> Successfully started `redis` (label: homebrew.mxcl.redis)
测试连接
% redis-cli
127.0.0.1:6379> set name zhang
OK
127.0.0.1:6379> get name
"zhang"
继续安装扩展
2.2.8 支持php5.6
https://github.com/phpredis/phpredis/archive/refs/tags/2.2.8.tar.gz
之后的版本,都直接不支持5.6了,直接支持7了。
下载
% sudo wget -c https://github.com/phpredis/phpredis/archive/refs/tags/2.2.8.tar.gz
如果没有wget,安装一下
brew install wget
解压
% sudo tar -zxvf 2.2.8.tar.gz
进入
% cd phpredis-2.2.8
Phpize(找到版本所在位置的phpize)
% sudo /opt/homebrew/Cellar/php@5.6/5.6.40/bin/phpize
Configuring for:
PHP Api Version: 20131106
Zend Module Api No: 20131226
Zend Extension Api No: 220131226
Configure 带上php对应的路径
% sudo ./configure --with-php-config=/opt/homebrew/Cellar/php@5.6/5.6.40/bin/php-config
make , make install
% sudo make && sudo make install
注意,两个地方都要加sudo,否则可能会生成错误
% sudo make && sudo make install
Build complete.
Don't forget to run 'make test'.
Installing shared extensions: /opt/homebrew/Cellar/php@5.6/5.6.40/pecl/20131226/
修改php.ini
% vim /opt/homebrew/etc/php/5.6/php.ini
添加
extension=redis.so
重启php
% brew services restart php@5.6
Stopping `php@5.6`... (might take a while)
==> Successfully stopped `php@5.6` (label: homebrew.mxcl.php@5.6)
==> Successfully started `php@5.6` (label: homebrew.mxcl.php@5.6)