nginx+php+mysql 整合memcached
在vista下安装memcached弄了一天没弄好,就是碰到这个问题过不去:当输入:“c:\memcached\memcached.exe -d install ”时出现“failed to install service or service is already installed”。不知道什么原因,网上找了好久,没什么可用的资料。
没办法只能到linux下去试试了,昨天试验了一下,结果和apache整合memcached的步骤差不多:
我在linux下安装的是nginx+php+mysql的软件包(不需要搭建平台),这里也给下软件包的下载:http://down.chinaz.com/soft/24050.htm(在装这个之前要装必要的支持库)
1、安装 libevent
# wget http://monkey.org/~provos/libevent-1.3b.tar.gz
# tar -zxf libevent-1.3b.tar.gz
# cd libevent-1.3b
# ./configure –prefix=/usr/local/libevent
# make
# make install
2、安装 memcached
# wget http://www.danga.com/memcached/dist/memcached-1.2.2.tar.gz
# tar -zxf memcached-1.2.2.tar.gz
# cd memcached-1.2.2
# ./configure –prefix=/usr/local/memcached –with-libevent==/usr/local/libevent
# make
# make install
3.安装PHP的memcache扩展,在http://pecl.php.net/package/memcache 选择相应想要下载的memcache版本。
# tar vxzf memcache-2.2.3.tgz
# cd memcache-2.2.3
# /usr/local/php/bin/phpize
# ./configure –enable-memcache –with-php-config=/usr/local/php/bin/php-config –with-zlib- dir
# make
# make install
4.上述安装完后会有类似这样的提示:
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/
5、修改配置文件
集成包安装默认的php.ini是在/etc下的,编辑php.ini
a、把php.ini中的extension_dir = “./”修改为
extension_dir = “/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/”
b、添加一行来载入memcache扩展:extension=memcache.so
4、启动 memcached
# /usr/local/memcached/bin/memcached -d -m 1024 -p 11211 -u root
参数说明 -m 指定使用多少兆的缓存空间 -p 指定要监听的端口 -u 指定以哪个用户来运行
5、不提示错误就OK了
6、Memcache环境测试:
运行下面的php文件,如果有输出This is a test!,就表示环境搭建成功。开始领略Memcache的魅力把!
<?php
$mem = new Memcache;
$mem->connect(”127.0.0.1″, 11211);
$mem->set(’key’, ‘This is a test!’, 0, 60);
$val = $mem->get(’key’);
echo $val;
?>
里面的:
./configure –enable-memcache –with-php-config=/usr/local/php/bin/php-config –with-zlib-dir
比如enable前面应该是两个-
有可能里面的目录是php5的哦,就是目录要看实际情况而定
vista下安装需要使用administrator身份登录才能安装。
The presentation is so unusual. I like that
This is an important topic that needs more attention.
that is very interesting indeed!
Good point on the concience
Memories are made of this – thanks for sharing Hope …