您的位置:首页 > 数据库 > Memcache

memcache PHP模块安装配置

2012-05-27 18:05 369 查看
1. 下载 memcache 安装包

memcache PHP模块下载地址: http://pecl.php.net/package/memcache
tar -zxvf memcache-2.2.6.tgz
cd memcache-2.2.6
/usr/local/php5/bin/phpize
./configure --enable-memcache --with-php-config=/usr/local/php5/bin/php-config --with-zlib-dir
make &&  make install


安装完后会有类似这样的提示:

Installing shared extensions: /usr/local/php5/lib/php/extensions/no-debug-non-zts-20060613

把这个记住,然后修改php.ini,把

extension_dir = "./"

修改为

extension_dir = "/usr/local/php5/lib/php/extensions/no-debug-non-zts-20060613"

并添加一行

extension=memcache.so

2、测试脚本

自己写一个PHP程序测试一下吧

<?php
$memcache = new Memcache; //创建一个memcache对象
$memcache->connect('localhost', 11211) or die ("Could not connect"); //连接Memcached服务器
$memcache->set('key', 'test'); //设置一个变量到内存中,名称是key 值是test
$get_value = $memcache->get('key'); //从内存中取出key的值
echo $get_value;
?>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: