安裝環境:CentOS 6.4 php
php的擴展memcache,不支持cas,因此咱們要裝memcached擴展,memcached擴展是基於libmemcached,因此要先安裝libmemcachedmemcached
1、下載軟件fetch
一、libmemcached下載地址:https://launchpad.net/libmemcached/+download.net
文件:memcached-2.2.0.tgzdebug
二、php-memcached下載地址:http://pecl.php.net/package/memcachedrest
文件:libmemcached-1.0.18.tar.gz code
2、安裝libmemcached (libmemcached-1.0.18.tar.gz)server
[root@localhost mysoft]#mkdir /usr/local/libmemcached
[root@localhost mysoft]# tar -zxvf libmemcached-1.0.18.tar.gzget
[root@localhost mysoft]# cd libmemcached-1.0.18it
[root@localhost mysoft]# ./configure --prefix=/usr/local/libmemcached/ --with-memcached
[root@localhost mysoft]# make
[root@localhost mysoft]# make install
3、安裝php-memcached(php-memcached-2.2.0.tgz)
[root@localhost mysoft]# mkdir /usr/local/phpmemcached
[root@localhost mysoft]# tar -zxvf php-memcached-2.2.0.tgz
[root@localhost mysoft]# cd memcached-2.2.0/
[root@localhost mysoft]# /phpstudy/server/php/bin/phpize
Configuring for: PHP Api Version: 20131106 Zend Module Api No: 20131226 Zend Extension Api No: 220131226
[root@localhost mysoft]# ./configure --enable-memcached --with-php-config=/phpstudy/server/php/bin/php-config --with-libmemcached-dir=/usr/local/libmemcached/ --disable-memcached-sasl
[root@localhost mysoft]# make
[root@localhost mysoft]# make install
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-zts-20131226/
[root@localhost mysoft]# ll /phpstudy/server/php/lib/php/extensions/no-debug-non-zts-20121212/
總用量 852 -rwxr-xr-x 1 root root 333097 9月 18 08:24 memcached.so -rwxr-xr-x. 1 root root 533480 9月 2 23:50 opcache.so
[root@localhost mysoft]# vi /phpstudy/server/php/etc/php.ini
加上 extension=memcached.so
[root@localhost mysoft]# phpstudy restart
4、安裝遇到的問題
一、安裝libmemcached過程當中不要忘了,--with-memcached,否則會提示你
checking for memcached... no
configure: error: "could not find memcached binary"
二、你的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也就沒什麼意思了。