mac下,php安装Memcached扩展

一、下载扩展

PECL :: Package :: memcached.

二、解压并进入扩展目录

三、使用 phpize 来生成编译检测脚本

/usr/local/Cellar/php@7.3/7.3.33_1/bin/phpize

四、./configure 来做编译配置检测

指定php配置目录,安装给指定的php版本

./configure --with-php-config=/usr/local/Cellar/php@7.3/7.3.33_1/bin/php-config

 提示错误:checking for zlib location... configure: error: memcached support requires ZLIB. Use --with-zlib-dir=<DIR> to specify the prefix where ZLIB headers and library are located

安装zlib

brew install zlib

指定zlib目录

./configure --with-php-config=/usr/local/Cellar/php@7.3/7.3.33_1/bin/php-config --with-zlib-dir=/usr/local/Cellar/zlib/1.2.11 

五、make 进行编译

make

六、make test 进行测试

make test

七、make install进行安装

make install

八、配置php.ini文件,打开memcached.so扩展

extension=memcached.so

九、使用链接

$MemcacheObj = new Memcached();

$MemcacheObj->addServer('127.0.0.1', '11211');
//$MemcacheObj->deleteMulti($MemcacheObj->getAllKeys());

($MemcacheObj->set('name', 1));
($MemcacheObj->set('name', 2));
($MemcacheObj->add('name2', 3));
($MemcacheObj->set('name', 5));


Dump($MemcacheObj->getAllKeys());


Dump($MemcacheObj->getMulti($MemcacheObj->getAllKeys()));

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值