windows上安装memcached、apc » 荒野无灯weblog

Keep It Simple, Stupid.

荒野无灯weblog

windows上安装memcached、apc

在Linux下就简单了:

pear install apc
pear install memcached

蛋疼的win按官方的step不行。
先去这里

下载编译好的win32程序

win32 binary: memcached-1.2.6-win32-bin.zip :
http://code.jellycan.com/memcached/

安装为win服务

memcached.exe  -d install

启动服务

memcached -d start

net start "memcached Server"

现在memcached已经启动,且监听11211端口。

调整内存限制

默认是64Mb 内存限制,可以把它调整为更大:
查找

HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/memcached  Server 

以 512 Mb 内存为例,将ImagePath修改为:

"C:/memcached/memcached.exe" -d runservice -m 512

如果只是开发调试用,可以写一个启动脚本start_memcached.bat:

@echo off
memcached -d start
wmic process get description, executablepath | findstr memcached.exe
pause

启用php_memcache 扩展

php_memcache.dll可以从http://downloads.php.net/pierre/ 下载。
php_apc.dll也是一样。

http://downloads.php.net/pierre/php_apc-20110109-5.3-vc9-x86.zip

http://downloads.php.net/pierre/php_memcache-2.2.6-5.3-vc9-x86.zip

修改php.ini ,添加:

extension=php_memcache.dll

php相关文档:http://php.net/manual/zh/book.memcache.php
http://php.net/manual/zh/book.apc.php

测试

connect("localhost",11211); // try 127.0.0.1 instead of localhost
                                           // if it is not working 

    echo "Server's version: " . $memcache->getVersion() . "
\n"; // we will create an array which will be stored in cache serialized $testArray = array('horse', 'cow', 'pig'); $tmp = serialize($testArray); $memcache->add("key", $tmp, 30); echo "Data from the cache:
\n"; print_r(unserialize($memcache->get("key"))); ?>

相关文档

http://memcached.org/
http://downloads.php.net/pierre/
http://www.codeforest.net/how-to-install-memcached-on-windows-machine
http://shikii.net/blog/installing-memcached-for-php-5-3-on-windows-7/

Tagged in :

All Comments (0)
Gravatar image
No Comments