先安装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_AUTOCONF environment variable. Then, rerun this script.
此时没有生成configure文件。
解决方法:
# cd /usr/src # wget http://ftp.gnu.org/gnu/m4/m4-1.4.9.tar.gz # tar -zvxf m4-1.4.9.tar.gz # cd m4-1.4.9/ # ./configure && make && make install # cd ../ # wget http://ftp.gnu.org/gnu/autoconf/autoconf-2.62.tar.gz # tar -zvxf autoconf-2.62.tar.gz # cd autoconf-2.62/ # ./configure && make && make install
或者更简单的办法是: # yum install m4 # yum install autoconf
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。