Linux 下的memcache+php工作原理及安装

Memcache(内存缓存):在内存中维护巨大的hash表,

                          Hash表结构

Key

Value

myString

字符串类型的数据

Myobject

对象类型的数据

Myarray

数组类型的数据

 

Memcache的工作原理


Memcache在Linux下的安装:

      安装memcache之前先安装一个支持各种事件的库文件 libevent

      Libevent有两种安装方式:

           yum  安装  

  yum –y install libevent

           源码安装:

                 tar  -zxvvf libevent*.tar.gz

                 cd   libevent*/

                 ./configure–prefix=/usr/local/libevent/

                 Make&& make install

        安装完libevent库后 安装memcache

                 Wget http://www.memcached.org/files/memcached-1.4.21.tar.gz

                 tar–zxvf memcached-1.4.21.tar.gz

                 cd  memcached-1.4.21/

#yum 安装libevent用:

                 ./configure–prefix=/usr/local/memcache –with-libevent=/usr/lib/

#源码安装用:

./configure –prefix=/usr/local/memcache –with-libevent=/usr/local/libevent/

Make && make install

#安装完memcache后启动

                 /usr/local/memcahe/bin/memcached  -d   -m128 –l 192.168.1.124 –p 11211 –u root

                         -d: 启动进程 

-m 128 : 指定memcache管理的内存大小   

-l:指定memcache服务器地址  

-p:监听的端口  

-uroot 用root用户运行memcache

停止memcache kill  “cat  /tmp/memcache.pid  ”  或  killall  memcached

安装php memcache的扩展库:

http://pecl.php.net/package/memcache 选择相应想要下载的memcache版本。、
   #tar vxzf memcache-2.2.6.tgz
   # cd memcache-2.2.6
   # /usr/local/php/bin/phpize
   # ./configure --enable-memcache --with-php-config=/usr/local/php/bin/php-config 
   # make
   # make install


修改php配置文件:

Vi  /usr/local/php/etc/php.ini


重启Apache

/usr/local/apache/bin/apachectl  restart

访问 PHPinfo文件结果如图:


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值