Mac下安装php-memcached扩展

一、先下载libmemcached

①:https://launchpad.net/libmemcached/+download

②:https://launchpad.net/libmemcached/1.0/1.0.18/+download/libmemcached-1.0.18.tar.gz

二、解压安装

mkdir -p /usr/local/libmemcached
// 遇到权限问题 执行
sudo mkdir -p /usr/local/libmemcached 
// 输入密码后即可
tar zxvf libmemcached-1.0.18.tar.gz

cd libmemcached-1.0.18
./configure --prefix=/usr/local/libmemcached --with-memcached        
// 注意:--with-memcached这个选项一定要加上
make && make install

三、可能会遇到的问题

问题①

libmemcached/byteorder.cc:66:10: error: use of undeclared identifier 'ntohll'
return ntohll(value);
libmemcached/byteorder.cc:75:10: error: use of undeclared identifier 'htonll'
return htonll(value);

问题②

clients/memflush.cc:42:19: error: comparison between pointer and integer ('char *' and 'int')
if (opt_servers == false)
~~~~~~~~~~~ ^ ~~~~~
clients/memflush.cc:51:21: error: comparison between pointer and integer ('char *' and 'int')
if (opt_servers == false)
~~~~~~~~~~~ ^ ~~~~~

 解决方案

sudo  vi libmemcached/byteorder.cc
在 #include "libmemcached/byteorder.h" 下面增加,
以下内容:
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif

sudo vi clients/memflush.cc
将两处 if (opt_servers == false)
替换成 if (opt_servers == NULL)

四、php-memcached安装

http://pecl.php.net/package/memcached 官方地址

②:wget https://pecl.php.net/get/memcached-3.1.3.tgz

五、解压安装memcached

tar zxvf memcached-3.1.3.tar
cd memcached-3.1.3
// 执行phpize命令生成configure建立php外挂模块
/usr/local/Cellar/php/7.2.12_2/bin/phpize
./configure --with-php-config=/usr/local/Cellar/php/7.2.12_2/bin/php-config --with-libmemcached-dir=/usr/local/libmemcached
make && make install

六、修改php.ini

extension=/Applications/MxSrvs/bin/php/lib/php/extensions/no-debug-non-zts-20151012/memcached.so

 

posted @ 2018-04-04 10:30  温柔的风  阅读(322)  评论(0编辑  收藏  举报