php连接memcached
先安装php的memcache扩展
# wget http://www.lishiming.net/data/p_w_upload/forum/memcache-2.2.3.tgz
# tar zxf memcache-2.2.3.tgz
# cd memcache-2.2.3
# /usr/local/php/bin/phpize
# ./configure --with-php-config=/usr/local/php/bin/php-config
# make && make install
安装完后会有类似这样的提示:Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/
把这个记住,然后修改php.ini,把 extension_dir = "./" 修改为extension_dir = "/usr/local/servers/php5/lib/php/extensions/no-debug-non-zts-20090626/"
或者指定新的位置,我以下是指定新的位置
并添加一行extension="memcache.so"
[root@localhost memcache-2.2.3]# make install
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/
[root@localhost memcache-2.2.3]# ls /usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/
memcache.so
[root@localhost memcache-2.2.3]# vim /usr/local/php/etc/php.ini
[root@localhost memcache-2.2.3]# ls /usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/
memcache.so
将memcache.so拷贝到/usr/local/php/ext 下
[root@localhost memcache-2.2.3]# mkdir /usr/local/php/ext #创建目录
[root@localhost memcache-2.2.3]# cp /usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/memcache.so /usr/local/php/ext/
[root@localhost memcache-2.2.3]# ls !$
ls /usr/local/php/ext/
memcache.so
添加路径
[root@localhost memcache-2.2.3]# vim /usr/local/php/etc/php.ini
检测添加memcached模块是否添加成功
[root@localhost memcache-2.2.3]# /usr/local/php/bin/php -m|grep memcache
memcache
测试能否连接memcached
[root@localhost memcache-2.2.3]# curl www.apelearn.com/study_v2/.memcache.txt > 1.php 2>/dev/null
下载一个1.php文件
[root@localhost memcache-2.2.3]# /usr/local/php/bin/php 1.php
Get key1 value: This is first value<br>Get key1 value: This is replace value<br>Get key2 value: Array
(
[0] => aaa
[1] => bbb
[2] => ccc
[3] => ddd
)
<br>Get key1 value: <br>Get key2 value: <br>[root@localhost memcache-2.2.3]#
[root@localhost memcache-2.2.3]# /usr/local/php/bin/phpize
Configuring for:
PHP Api Version: 20090626
Zend Module Api No: 20090626
Zend Extension Api No: 220090626
Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONFenvironmentvariable.Then,rerunthisscript.
此时没有生成configure文件。
解决方法:
#cd/usr/src#wgethttp://ftp.gnu.org/gnu/m4/m4-1.4.9.tar.gz#tar-zvxfm4-1.4.9.tar.gz#cdm4-1.4.9/#./configure&&make&&makeinstall#cd../#wgethttp://ftp.gnu.org/gnu/autoconf/autoconf-2.62.tar.gz#tar-zvxfautoconf-2.62.tar.gz#cdautoconf-2.62/#./configure&&make&&makeinstall
或者更简单的办法是:#yuminstallm4#yuminstallautoconf
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。