php安装memcache扩展

1、先下载 memcached服务端

wget http://www.memcached.org/files/memcached-1.4.20.tar.gz

yum -y install libevent

yum -y install libevent-devel

./configure    && make && make install

测试:

telnet 127.0.0.1 11211

Trying 127.0.0.1...

Connected to 127.0.0.1.

Escape character is ‘^]‘.

表示成功了

启动/结束

memcached -d -m 10 -u root -l 172.25.43.71 -p 11200 -c 256 -P /tmp/memcached.pid

-d 选项是启动一个守护进程,

-m 是分配给Memcache使用的内存数量,单位是MB,这里是10MB

-u 是运行Memcache的用户,这里是root

-l 是监听的服务器IP地址,如果有多个地址的话,这里指定了服务器的IP地址192.168.0.122

-p 是设置Memcache监听的端口,这里设置了12000,最好是1024以上的端口

-c 选项是最大运行的并发连接数,默认是1024,这里设置了256,按照你服务器的负载量来设定

-P 是设置保存Memcache的pid文件

kill `cat /tmp/memcached.pid`

2、下载PHP的memcache

wget http://pecl.php.net/get/memcache-2.2.7.tgz

tar zxvf memcache-2.2.7.tgz

cd memcache-2.2.7

/usr/local/php/bin/phpize //用phpize编译

./configure --with-php-config=/usr/local/php/bin/php-config --enable-memcache

make && make install

把memcache.so 放到php.ini extension = /usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/memcache.so

3、获取memcache里的所有的key

$oMem = new Memcache;

$host = ‘172.25.43.71‘;

$port = ‘11200‘;

$oMem->connect($host,$port);

$items = $oMem->getExtendedStats(‘items‘);

$items=$items["$host:$port"][‘items‘];

foreach($items as $key=>$values){

$number=$key;

$str=$oMem->getExtendedStats ("cachedump",$number,0);

var_dump($str);

$line=$str["$host:$port"];

if( is_array($line) && count($line)>0){

foreach($line as $key=>$value){

echo $key.‘=>‘;

print_r($oMem->get($key));

echo "\r\n";

}

}

}

时间: 2024-08-10 07:23:05

php安装memcache扩展的相关文章

win10 64位安装memcache扩展和开启redis扩展

前面有关于win10下搭建wamp环境的介绍,在此不在赘述,php操作memcache有memcache库和memcached库,其中memcache是php内置的扩展库,支持面向对象和面向过程两种操作,memcached是基于libmemcached的一套第三方扩展库,仅支持面向对象方式操作,相对于memcache扩展而言,功能更加强大,方法更加丰富,效率更高.下面介绍下在window环境下如何安装memcache扩展和开启redis扩展, 下载文件 附件有memcached的安装文件和php

linux-CentOS6.4安装Memcached+memcached扩展+安装memcache扩展+Memcache同步SESSION的几种方法

一.编译环境的准备 yum install gcc  yum install gcc-c++ libstdc++-devel  yum install zlib-devel 二.源码包准备 wget http://monkey.org/~provos/libevent-1.4.14b-stable.tar.gzwget http://memcached.googlecode.com/files/memcached-1.4.15.tar.gz 三.安装与配置 1.安装libevent tar zx

CentOS环境PHP安装memcache扩展

安装memcache yum install memcached 安装libmemcached库 yum install libmemcached PHP安装Memcache扩展 [email protected]] wget -c http://pecl.php.net/get/memcache-3.0.8.tgz [root@blog.phpha.com] tar -zxvf memcache-3.0.8.tgz [root@blog.phpha.com] cd memcache-3.0.8

Linux 安装Memcache扩展支持

查看相关软件包 yum search memcached 安装memcache yum -y install memcachedMemcache关联php yum -y install php-pecl-memcache验证安装结果 memcached -h php -m | grep memcache 添加PHP的Memcache扩展 yum install php-pecl-memcache yum install zlib-devel pecl install memcache 在PHP配

yum安装PHP的安装memcache扩展全攻略

下载libevent ,这个是memcache的支持.从网上找到源码直接编译安装.注:CentOS默认是安装了的所以不需要再这一步.为测试libevent是否安装成功: # ls -al /usr/lib | grep libevent lrwxrwxrwx 1 root root 21 11?? 12 17:38 libevent-1.2.so.1 -> libevent-1.2.so.1.0.3 -rwxr-xr-x 1 root root 263546 11?? 12 17:38 libe

Wamp环境中给PHP安装MemCache扩展

一.安装Memcache: 1.版本:5.3 Thread Safe (TS) x86 2.下载地址: Memcache扩展:http://pecl.php.net/package/memcache/3.0.8/windows Memcache服务器:http://blog.couchbase.com/memcached-144-windows-32-bit-binary-now-available 3.安装目录: 扩展安装目录:D:\Wamp\php-5.3.10\ext 服务器安装目录:D:

Linux下php安装memcache扩展

安装环境:CentOS 6.4 php扩展memcache的作用是为了支持memcached数据库缓存服务器,下面是安装方法. 1.下载 下载地址:http://pecl.php.net/package/memcache 文件名:memcache-3.0.8.tgz 文件下载成功后上传至/usr/local目录 2.安装 [[email protected] local]# tar -zxvf memcache-3.0.8.tgz[email protected] local]# cd memc

Linux下安装memcache扩展

memcache是php的一个扩展模块,安装前应先保证目前具备php环境. 先找到phpize的存在目录(如果是通过yum安装的php,则存在于/usr/bin中,如果没找到它们,则#yum install php-devel并重启) 解压memcache压缩包后,"进入解压出的文件夹中".接下来使用phpzie将memcache编译到php扩展模块中. #/usr/bin/phpize #./configure --with-php-config=/usr/bin/php-confi

wamp环境 安装memcache 扩展

这两天在研究tp的memcached缓存 总是遇到坑 在网上找了很多教程看终于弄出来了现在拿出来分享 首先安装memcached下载memcache压缩包 使用cmd以管理员命令去安装 E:\wamp\bin\memcached>memcached.exe -d install 安装命令 E:\wamp\bin\memcached>memcached.exe -d start 开启memcached 然后把附件里的php_memcache.dll 放在php下的ext扩展文件夹下 然后去修改p

ubuntu在xampp下安装memcache扩展

sudo wget http://pecl.php.net/get/memcache-2.2.1.tgz sudo tar vxzf memcache-2.2.1.tgz cd memcache-2.2.1/ sudo /opt/lampp/bin/phpize ./configure --with-php-config=/opt/lampp/bin/php-config --enable-memcache #make #make install (会显示编译好了memcache.so,并安装到