PHP之——Centos 6.5 基于libmemcached,php扩展memcached的安装

转载请注明出处:http://blog.csdn.net/l1028386804/article/details/51281392

安装环境:CentOS 6.5

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也就没什么意思了。


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

冰 河

可以吃鸡腿么?

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值