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-ammake[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.loin 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 directoryin 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 directorymake[1]: *** [libmemcached/libmemcached_libmemcached_la-analyze.lo] 错误 1make[1]: *** 正在等待未完成的任务....make[1]: *** [libmemcached/libmemcached_libmemcached_la-allocators.lo] 错误 1make[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.ini中增加extension = memcached.so
重启php-fpm和webserver(我这边用的是nginx)