Memcached 作为一个高性能的分布式内存对象缓存系统,用于动态Web应用以减轻数据库负载。 本文为Memcached的安装测试实例,带大家一起学习memcached的安装、php扩展及环境测试,希望对大家有所帮助。 1,memcached安装
复制代码代码如下:
[root@localhost src]# wget http://memcached.googlecode.com/files/memcached-1.4.5.tar.gz
[root@localhost src]# wget http://www.monkey.org/~provos/libevent-2.0.10-stable.tar.gz [root@localhost src]# tar zxf libevent-2.0.10-stable.tar.gz [root@localhost src]# cd libevent-2.0.10-stable [root@localhost libevent-2.0.10-stable]# ./configure --prefix=/usr [root@localhost libevent-2.0.10-stable]# make [root@localhost libevent-2.0.10-stable]# make install [root@localhost libevent-2.0.10-stable]# cd ../ [root@localhost src]# tar zxf memcached-1.4.5.tar.gz [root@localhost src]# cd memcached-1.4.5 [root@localhost memcached-1.4.5]# ./configure --prefix=/usr/local/memcached --with-libevent=/usr [root@localhost memcached-1.4.5]# make [root@localhost memcached-1.4.5]# make install [root@localhost memcached-1.4.5]# /usr/local/memcached/bin/memcached -d -m 10 -l 192.168.1.46 -p 11211 -u root -c 256 -P /usr/local/memcached/memcached.pid
memcached参数:
2,添加memcache扩展至php
复制代码代码如下:
[root@localhost src]# tar zxf memcache-2.2.6.tgz
[root@localhost src]# cd memcache-2.2.6 [root@localhost memcache-2.2.6]# /usr/local/php/bin/phpize [root@localhost memcache-2.2.6]# ./configure --with-php-config=/usr/local/php/bin/php-config [root@localhost memcache-2.2.6]# make [root@localhost memcache-2.2.6]# make install [root@localhost src]# ll /usr/local/php5/lib/php/extensions/no-debug-non-zts-20060613/memcache.so
修改php.ini中的extension_dir = “./”为
3,memcache环境测试
复制代码代码如下:
[root@localhost html]# pwd
/usr/local/nginx/html
复制代码代码如下:
[root@localhost html]# vi mem.php
配置成功,测试页面: |