一、下载扩展
二、解压并进入扩展目录
三、使用 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()));