使用宝塔自带的 php 扩展安装功能,安装 memcached 失败,截取报错信息最后一段:

checking whether to enable memcached msgpack serializer support... no
checking whether to enable memcached sasl support... yes
checking whether to enable memcached protocol support... no
checking whether to use system FastLZ library... no
checking for ZLIB... yes, shared
checking for pkg-config... /bin/pkg-config
checking for zlib location... /usr
checking for session includes... /www/server/php/82/include/php
checking for memcached session support... enabled
checking for memcached igbinary support... disabled
checking for memcached msgpack support... disabled
checking for libmemcached location... configure: error: Unable to find memcached.h under /usr/local/libmemcached
make: *** No targets specified and no makefile found. Stop.
Install failed

关键信息是后面这一句:

checking whether to enable memcached msgpack serializer support... no
checking whether to enable memcached sasl support... yes
checking whether to enable memcached protocol support... no
checking whether to use system FastLZ library... no
checking for ZLIB... yes, shared
checking for pkg-config... /bin/pkg-config
checking for zlib location... /usr
checking for session includes... /www/server/php/82/include/php
checking for memcached session support... enabled
checking for memcached igbinary support... disabled
checking for memcached msgpack support... disabled
checking for libmemcached location... configure: error: Unable to find memcached.h under /usr/local/libmemcached
make: *** No targets specified and no makefile found. Stop.
Install failed

意思是在/usr/local/libmemcached 这个路径下找不到 memcached.h 文件。

我看了下确实没有这个目录,使用 yum 命令安装了 libmemcachedlibmemcached-devel 依然没有这个目录。

看到网上说需要编译安装,而且 yum 上的版本只到 1.0.16,最新版是 1.0.18,我也不清楚是安装方式的问题还是版本的问题,但是我通过编译安装 1.0.18 版本的 libmemcached 后,问题解决了。

安装过程

获取源码包

可以通过 wget 下载,但我安装的时候这个网站超时响应。

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

也可以到这个网站直接下载:https://launchpad.net/libmemcached/+download

解压

tar -xzvf libmemcached-1.0.18.tar.gz

此处如果解压参数给的是 zxvf 的话,会遇到报错

tar: Old option 'f' requires an argument

顺便温习一下 Linux 的 tar 指令

编译安装

# 进入目录
cd libmemcached-1.0.18

# 配置 libmemcached 和 memcached 的安装路径
./configure --prefix=/usr/local/libmemcached --with-memcached=/usr/local/memcached

# 编译安装
make && make install

安装完成后可以在/usr/local 目录下看到 libmemcached 文件夹啦。

然后就是使用宝塔的 php 扩展安装功能,即可成功装上 memcached 扩展。

订阅评论
提醒
guest

0 评论
内联反馈
查看所有评论