首页 > 服务器 > nginx+php+mysql 整合memcached

nginx+php+mysql 整合memcached

2009年03月31号
查看评论 发表评论 1,071次浏览

 在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;
?>

类别服务器 标签
  1. 高手
    发表于 2009年04月07号 18时51分53秒 | 1楼

    里面的:
    ./configure –enable-memcache –with-php-config=/usr/local/php/bin/php-config –with-zlib-dir

  2. 高手
    发表于 2009年04月07号 18时52分29秒 | 2楼

    比如enable前面应该是两个-

  3. 高手
    发表于 2009年04月07号 18时53分53秒 | 3楼

    有可能里面的目录是php5的哦,就是目录要看实际情况而定

  4. 匿名
    发表于 2009年07月21号 23时25分28秒 | 4楼

    vista下安装需要使用administrator身份登录才能安装。

  5. mbt anti shoe
    发表于 2010年06月23号 02时27分13秒 | 5楼

    The presentation is so unusual. I like that

  6. arizona cardinals superbowl jerseys
    发表于 2010年07月01号 10时09分20秒 | 6楼

    This is an important topic that needs more attention.

  7. Cheap Timberland Boots
    发表于 2010年07月19号 20时47分38秒 | 7楼

    that is very interesting indeed!

  8. kobe shoes
    发表于 2010年07月25号 16时16分01秒 | 8楼

    Good point on the concience

  9. Lacoste Shoes 2010
    发表于 2010年07月27号 16时53分43秒 | 9楼

    Memories are made of this – thanks for sharing Hope …

  1. 目前没有通告
你必需 登陆 才能发表评论.