Mac m1 安装php redis扩展

目录

安装redis

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> 

安装redis扩展

我用的是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

Phpize(找到版本所在位置的phpize)

% 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

Configure 带上php对应的路径

% sudo ./configure --with-php-config=/opt/homebrew/Cellar/php@7.4/7.4.25/bin/php-config

make&make install

% 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/

修改php.ini

vim /opt/homebrew/etc/php/7.4/php.ini

添加

extension=redis.so

重启php

% 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)

查看是否有redis扩展

% php -m | grep redis
redis

成功!


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值