memcached 安装配置(PHP对memcached的支持是由基于libmemached的PHP memcached扩展实现的)
1.安装memcached
brew install memcached
或者
pecl install memcached(未成功安装,各种依赖没正确找到)
brew install memcached
2. 安装libmemcached
brew install libmemcached
3.安装memcache的依赖:openssl和libevent会自动下载并安装。
安装php扩展
下载地址1:https://github.com/php-memcached-dev/php-memcached/releases
下载地址2:http://pecl.php.net/package/memcached
或者:
pecl download memcached
open memcached-3.1.3.tgz && cd memcached-3.1.3
/usr/local/Cellar/php/7.3.8/bin/phpize (phpize是帮助用来在已编译好的php外,编译php扩展用的脚本,用来生成configure、make等文件。)
有时执行这个命令会报错:Cannot find autoconf. Please check your autoconf installation and the $PHP_AUTOCONF environment variable. Then, rerun this script.
解决方法:brew install autoconf
4.phpize完成后,依次实行如下命令实现编译和安装:
sudo ./configure --with-php-config=/usr/local/Cellar/php/xxx/bin/php-config --with-zlib-dir=/usr/local/Cellar/zlib/1.2.11
(如果没有zlib的话就安装zlib brew install zlib (/usr/local/Cellar/zlib))
make (若提示没有make文件,则上一步没有正确完成,需要安装所需的依赖)
make install
5.配置php.ini
extension = “/usr/local/Cellar/php/xxx/pecl/20180731/memcached.so”
打开phpinfo()页面,查看memcache是否已经加载成功:
6.查看memcached的运行状态
echo stats | nc 127.0.0.1 11211
版权声明:本文为qq_36500835原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。