标签:
php的扩展memcache,不支持cas,所以我们要装memcached扩展,memcached扩展是基于libmemcached,所以要先安装libmemcached
一、下载软件
1、libmemcached下载地址:https://launchpad.net/libmemcached/+download
文件:memcached-2.2.0.tgz
2、php-memcached下载地址:http://pecl.php.net/package/memcached
文件:libmemcached-1.0.18.tar.gz
二、安装libmemcached
[root@vm15 local]# mkdir -p libmemcached
[root@vm15 local]# tar zxvf libmemcached-1.0.18.tar.gz
[root@vm15 local]# cd libmemcached-1.0.18
[root@vm15 libmemcached-1.0.18]# ./configure --prefix=/usr/local/libmemcached --with-memcached
[root@vm15 libmemcached-1.0.18]# make
[root@vm15 libmemcached-1.0.18]# make install
三、安装php-memcached
[root@vm15 local]# mkdir -p phpmemcached
[root@vm15 local]# tar zxvf memcached-2.2.0.tgz
[root@vm15 local]# cd memcached-2.2.0
[root@vm15 memcached-2.2.0]# /usr/local/php/bin/phpize
Configuring for:
PHP Api Version: 20131106
Zend Module Api No: 20131226
Zend Extension Api No: 220131226
[root@vm15 memcached-2.2.0]# ./configure --enable-memcached --with-php-config=/usr/local/php/bin/php-config --with-libmemcached-dir=/usr/local/libmemcached --disable-memcached
-sasl
[root@vm15 memcached-2.2.0]# make
[root@vm15 memcached-2.2.0]# make install
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-zts-20131226/
[root@vm15 memcached-2.2.0]# ll /usr/local/php/lib/php/extensions/no-debug-zts-20131226/
total 2140
-rwxr-xr-x. 1 root root 325608 Dec 30 15:59 memcached.so
-rwxr-xr-x. 1 root root 453766 Dec 30 17:44 memcache.so
-rwxr-xr-x. 1 root root 540834 Dec 19 15:38 opcache.so
-rwxr-xr-x. 1 root root 861055 Dec 30 16:47 redis.so
[root@vm15 memcached-2.2.0]# vi + /usr/local/php/lib/php.ini
加上extension=memcached.so
[root@vm15 memcached-2.2.0]# /usr/local/apache2/bin/apachectl restart
查看phpinfo可以看到支持了
四、安装遇到的问题
1、安装libmemcached过程中不要忘了,--with-memcached,不然会提示你
checking for memcached... no
configure: error: "could not find memcached binary"
2、你的memcached是不是1.2.4以上的,如果不是会提示你
clients/ms_thread.o: In function `ms_setup_thread‘:
/home/zhangy/libmemcached-0.42/clients/ms_thread.c:225: undefined reference to `__sync_fetch_and_add_4‘
clients/ms_thread.o:/home/zhangy/libmemcached-0.42/clients/ms_thread.c:196: more undefined references to `__sync_fetch_and_add_4‘ follow
collect2: ld returned 1 exit status
make[2]: *** [clients/memslap] Error 1
make[2]: Leaving directory `/home/zhangy/libmemcached-0.42‘
解决办法是--disable-64bit CFLAGS="-O3 -march=i686",如果不用这个64位的long型数据,我想php扩展memcached,memcache也就没什么区别了,装memcached也就没什么意思了。
CentOS 6.4 基于libmemcached,php扩展memcached的安装
标签:
原文地址:http://www.cnblogs.com/yangxia-test/p/4195288.html