這個問題之前就遇到過,記得最後是通過下載源碼包來指定路徑的,今天又從新安裝環境結果一定要試試,因為我知道只要安裝這種libmemcached-devdev包就一定有標頭檔,結果最後通過查詢資料真的讓我找到了,以下記錄這個過程
首先安裝依賴以編譯安裝
sudo apt-get install libmemcached libmemcached-devpecl download memcachedtar zxvf memcached.tar.gzcd memcachedphpize./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/libmemcachedchecking 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/libmemcachedsudo 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-saslsudo makesudo make install