首頁 > php教程 > php手册 > 主體

php的memcached扩展

WBOY
發布: 2016-06-06 20:01:58
原創
1044 人瀏覽過

1。安装libmemcached 下载 libmemcached1.0.16: wget https://launchpad.net/libmemcached/1.0/1.0.16/download/libmemcached-1.0.16.tar.gz tar -xzflibmemcached-1.0.16.tar.gz ./configure -prefix=/usr/local/libmemcached -with-memcached=/usr/local/

1。安装libmemcached

下载 libmemcached1.0.16:

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

tar -xzf libmemcached-1.0.16.tar.gz

./configure -prefix=/usr/local/libmemcached -with-memcached=/usr/local/memcached/bin/memcached

make

出现如下错误

make -j3  all-am
make[1]: Entering directory `/root/soft/libmemcached-1.0.16'
  CXX      libhashkit/libmemcached_libmemcached_la-aes.lo
  CXX      libhashkit/libmemcached_libmemcached_la-algorithm.lo
  CXX      libhashkit/libmemcached_libmemcached_la-behavior.lo
  CXX      libhashkit/libmemcached_libmemcached_la-crc32.lo
  CXX      libhashkit/libmemcached_libmemcached_la-digest.lo
  CXX      libhashkit/libmemcached_libmemcached_la-encrypt.lo
  CXX      libhashkit/libmemcached_libmemcached_la-fnv_32.lo
  CXX      libhashkit/libmemcached_libmemcached_la-fnv_64.lo
  CXX      libhashkit/libmemcached_libmemcached_la-function.lo
  CXX      libhashkit/libmemcached_libmemcached_la-has.lo
  CXX      libhashkit/libmemcached_libmemcached_la-hashkit.lo
  CXX      libhashkit/libmemcached_libmemcached_la-jenkins.lo
  CXX      libhashkit/libmemcached_libmemcached_la-ketama.lo
  CXX      libhashkit/libmemcached_libmemcached_la-md5.lo
  CXX      libhashkit/libmemcached_libmemcached_la-murmur.lo
  CXX      libhashkit/libmemcached_libmemcached_la-murmur3.lo
  CXX      libhashkit/libmemcached_libmemcached_la-one_at_a_time.lo
  CXX      libhashkit/libmemcached_libmemcached_la-murmur3_api.lo
  CXX      libhashkit/libmemcached_libmemcached_la-rijndael.lo
  CXX      libhashkit/libmemcached_libmemcached_la-str_algorithm.lo
  CXX      libhashkit/libmemcached_libmemcached_la-strerror.lo
  CXX      libhashkit/libmemcached_libmemcached_la-string.lo
  CXX      libhashkit/libmemcached_libmemcached_la-nohsieh.lo
  CXX      libmemcached/libmemcached_libmemcached_la-allocators.lo
  CXX      libmemcached/libmemcached_libmemcached_la-analyze.lo
In file included from ./libmemcached/common.h:114,
                 from libmemcached/analyze.cc:1:
./libmemcached-1.0/memcached.h:46:27: error: tr1/cinttypes: No such file or directory
In file included from ./libmemcached/common.h:114,
                 from libmemcached/allocators.cc:38:
./libmemcached-1.0/memcached.h:46:27: error: tr1/cinttypes: No such file or directory
make[1]: *** [libmemcached/libmemcached_libmemcached_la-analyze.lo] 错误 1
make[1]: *** 正在等待未完成的任务....
make[1]: *** [libmemcached/libmemcached_libmemcached_la-allocators.lo] 错误 1
make[1]: Leaving directory `/root/soft/libmemcached-1.0.16'
make: *** [all] 错误 2
登入後複製

经查,发现是gcc版本问题

于是先更新gcc版本

yum install gcc44 gcc44-c++ libstdc++44-devel

export CC=/usr/bin/gcc44

export CXX=/usr/bin/g++44


重新执行libmemcached 的 configure:

./configure -prefix=/usr/local/libmemcached -with-memcached=/usr/local/memcached/bin/memcached

make

make install

成功了


2。安装php的memcached扩展

cd memcached-1.4.5;

执行了几次/usr/local/php/bin/phpize,都报如下错误

Cannot find config.m4. 
Make sure that you run '/usr/local/php/bin/phpize' in the top level source directory of the module
登入後複製

后来发现这个不是php的memcached的扩展目录,然后找到memcached的php扩展目录memcached-1.0.2,苍天,我哪儿知道这个是memcached的php扩展目录啊,我还以为是低版本的memcached软件的源代码目录呢。


cd memcached-1.0.2;

执行

/usr/local/php/bin/phpize

世界变得美好了,先把结果拷贝到一个记事本里

然后执行./configure --with-php-config=/usr/local/php/bin/php-config --with-libmemcached-dir=/usr/local/libmemcached

命运依然多舛,又报错

make: *** [php_memcached.lo] 错误 1
登入後複製

发现是libmemcached版本过高,换低版本

然后继续configure,make ,make install

成功,真不容易

php的memcached扩展


然后在php.ini中增加extension = "memcached.so"

重启php-fpm和webserver(我这边用的是nginx)



相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門推薦
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!