编译php-memcached 扩展时候遇到的问题Unable to find memcached.h

Posted coder_up

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了编译php-memcached 扩展时候遇到的问题Unable to find memcached.h相关的知识,希望对你有一定的参考价值。

这个问题之前就遇到过,记得最后是通过下载源码包来指定路径的,今天又从新安装环境结果一定要试试,因为我知道只要安装这种libmemcached-devdev包就一定有头文件,结果最后通过查询资料真的让我找到了,以下记录这个过程

首先安装依赖以编译安装

sudo apt-get install libmemcached libmemcached-dev
pecl download memcached
tar zxvf memcached.tar.gz
cd memcached
phpize
./configure --with-libmemcached-dir=这个目录可使用如下命令查找

dpkg -L libmemcached-dev | grep memcached.h

/usr/include/libmemcached-1.0/memcached.hpp
/usr/include/libmemcached-1.0/struct/memcached.h
/usr/include/libmemcached-1.0/memcached.h
/usr/include/libmemcached/memcached.hpp
/usr/include/libmemcached/memcached.h

这样明明看到了memcached.h文件了,那么路径就写成/usr/include/libmemcached可是不行,保错

./configure --with-libmemcached-dir=/usr/include/libmemcached

checking for libmemcached location... configure: error: Unable to find memcached.h under /u/weiz/libmemcached-1.0.16

通过查看
https://github.com/php-memcached-dev/php-memcached/blob/master/config.m4#L277
可以看到
if test ! -f "$PHP_LIBMEMCACHED_DIR/include/libmemcached/memcached.h";
原来他要去这个路径include/libmemcached/下寻找,难怪出错

接下来执行

sudo mkdir -p /usr/lib/x86_64-linux-gnu/include/libmemcached
sudo ln -s /usr/include/libmemcached/memcached.h /usr/lib/x86_64-linux-gnu/include/libmemcached/memcached.h

接下来在执行就好了

sudo ./configure --with-php-config=/usr/local/php/bin/php-config --enable-memcached --with-libmemcached-dir=/usr/lib/x86_64-linux-gnu --disable-memcached-sasl

sudo make
sudo make install

以上是关于编译php-memcached 扩展时候遇到的问题Unable to find memcached.h的主要内容,如果未能解决你的问题,请参考以下文章

再议php-memcached扩展的编译,进一步理解phpize

centos下安装php扩展php-memcached

ubuntu源码编译安装memcached和php-memcache 扩展

php-memcached扩展升级小记

编译libmemcached

centos7中php使用memcache