设为首页收藏本站
开启辅助访问

创星网络[分享知识 传递快乐]

 找回密码
 立即注册

QQ登录

只需一步,快速开始

用新浪微博登录

只需一步,快速搞定

搜索

Linux下php使用phpize编译安装 pecl-memcache扩展

2012-8-7 22:06| 发布者: cryinglily| 查看: 400| 评论: 0|原作者: luinstein

摘要: 1、安装Memcached root@tonyvicky:# tar vxzf memcached-1.1.12.tar.gz root@tonyvicky:# cd memcached-1.1.12 root@tonyvicky:# ./configure --prefix=/usr/local/memcached root@tonyvicky:# make root@tonyvicky: ...
1、安装Memcached
root@tonyvicky:# tar vxzf memcached-1.1.12.tar.gz
root@tonyvicky:# cd memcached-1.1.12
root@tonyvicky:# ./configure --prefix=/usr/local/memcached
root@tonyvicky:# make
root@tonyvicky:# make install
安装完之后要启动服务
root@tonyvicky:# cd /usr/local/memcached/bin
root@tonyvicky:# ./memcached -d -m 50 -p 11211 -u root
参数说明 -m 指定使用多少兆的缓存空间;-p 指定要监听的端口; -u 指定以哪个用户来运行
2、安装memcache PHP模块
root@tonyvicky:# tar vxzf memcache-1.5.tgz
root@tonyvicky:# cd memcache-1.5
root@tonyvicky:# /usr/local/php/bin/phpize
root@tonyvicky:# ./configure --enable-memcache --with-php-config=/usr/local/php/bin/php-config --with-zlib-dir
root@tonyvicky:# make
root@tonyvicky:# make install
安装完后会有类似这样的提示:
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20050922/
把这个记住,然后修改php.ini,把
extension_dir = "./"
修改为
extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20050922/"
并添加一行
extension=memcache.so
3、测试脚本
自己写一个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;
?>

from:http://dev.maidou5.com/archives/404.html




鲜花

握手

雷人

路过

鸡蛋

相关分类

QQ|Archiver|手机版|小黑屋|创星网络 ( 苏ICP备11027519号|网站地图  

GMT+8, 2025-7-3 23:12 , Processed in 0.062559 second(s), 18 queries .

Powered by Discuz! X3

© 2001-2013 Comsenz Inc.

返回顶部