windows上安装memcached、apc

在Linux下就简单了:

1
2
pear install apc
pear install memcached

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

下载编译好的win32程序

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

安装为win服务

1
memcached.exe  -d install

启动服务

1
memcached -d start

1
net start "memcached Server"

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

调整内存限制

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

1
HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/memcached  Server

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

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

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

1
2
3
4
@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 ,添加:

1
extension=php_memcache.dll

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

测试

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<?php
    $memcache = new Memcache; // instantiating memcache extension class
    $memcache->connect("localhost",11211); // try 127.0.0.1 instead of localhost
                                           // if it is not working

    echo "Server's version: " . $memcache->getVersion() . "<br />\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:<br />\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/

更多
No Responses Post a comment

Leave a Reply

Note: You may use basic HTML in your comments. Your email address will not be published.

Subscribe to this comment feed via RSS