memcached
memcached简介:Memcached 是一个高性能的分布式内存对象缓存系统,用于动态Web应用以减轻数据库负载。它通过在内存中缓存数据和对象来减少读取数据库的次数,从而提高动态、数据库驱动网站的速度。Memcached基于一个存储键/值对的hashmap。其守护进程(daemon )是用C写的,但是客户端可以用任何语言来编写,并通过memcached协议与守护进程通信。
实验环境:
server1:172.25.45.1
iptables off and selinux disabled
memcached的安装:
1
2
|
yum
install
memcached
/etc/sysconfig/memcached
start
|
1
2
|
yum
install
telnet
telnet 127.0.0.1 11211
|
2.配置
php -m 可以看到php不支持memcached
解压memcache-2.2.5.tgz
进入解压目录
运行phpize ##会自动生成configure
1
|
.
/configure
--prefix=
/usr/local/lnmp/php/modules
--
enable
-memcache
|
1
2
|
make
make
install
|
1
|
cd
/usr/local/lnmp/php/lib/php/extensions/no-debug-non-zts-20131226/
|
1
|
vim
/usr/local/lnmp/php/etc/php
.ini
|
863 extension=memcache.so #添加
1
2
|
cd
/root/memcache-2
.2.5
cp
example.php memcache.php
/usr/local/lnmp/nginx/html/
|
1
2
3
|
cd
/usr/local/lnmp/nginx/html/
vim example.php
##分析信息不做修改
vim memcache.php
|
将23行ADMIN_PASSWORD后的password改掉,如westos
将28行$MEMCACHE_SERVERS[]后改为'localhost:11211'或'127.0.0.1:11211'
将29行注释掉
http://172.25.45.1/example.php ##访问网站并多次刷新
http://172.25.45.1/memcache.php ##查看命中率
转载于:https://blog.51cto.com/hgh1882928/1844097