Home > Article > Backend Development > Steps to install Memcached under Windows
(In fact, installation under Windows is relatively simple)
Source package preparation:
1, memcached 1.2.1 for Win32 binaries
This is the latest version of memcached on the Win32 server, just download it directly;
2, php_memcache-5.2-Win32-vc6-x86-20090408.zip
This is php The required PECL extension is the php_memcache extension; (it must be the same as your own PHP version, I use 5.2.1)
With the source code package, let’s start feasting, follow the steps below
1. Unzip the first package and put it under a certain disk, such as c:memcached
2. Enter 'c:memcachedmemcached.exe -d install' in the terminal (i.e. cmd command interface) Installation
3. Then enter: 'c:memcachedmemcached.exe -d start' to start. (Note: In the future, memcached will be automatically started as a service of Windows every time you boot up. In this way, the server side has been installed)
4. Unzip the second package. There will be only one php_memcache.dll file in it. Put it into usr/local/php5/ext/
5. Add a line 'extension=php_memcache.dll' to C:WINDOWSphp.ini (I don’t know why PHP has two configuration files, one in usr/local/ php5/php.ini, and the other one is in C:/WINDOWS/, and only changing the previous configuration file did not work, so I also changed the php.ini in WINDOWS! )
6. Then add:
Copy the code The code is as follows:
[Memcache] memcache.allow_failover = 1 memcache.max_failover_attempts=20 memcache.chunk_size =8192 memcache.default_port = 11211
Finally Okay, just put it below what you just wrote "extension=php_memcache.dll". (These are some default configurations)
6. Restart Apache, and then check phpinfo. If there is a description of memcache, then the installation is successful!
Test run:
Write an example.php file: (For more usage methods, please refer to the Memcache Functions instructions in the PHP manual)
Copy code The code is as follows:
<?php $memcache = new Memcache; $memcache->connect('localhost', 11211) or die ("Could not connect"); $version = $memcache->getVersion(); echo "Server's version: ".$version." \n"; $tmp_object = new stdClass; $tmp_object->str_attr = 'test'; $tmp_object->int_attr = 123; $memcache->set('key', $tmp_object, false, 10) or die ("Failed to save data at the server"); echo "Store data in the cache (data will expire in 10 seconds) \n"; $get_result = $memcache->get('key'); echo "Data from the cache: \n"; var_dump($get_result); ?>
If there is output:
Copy code The code is as follows:
Server's version: 1.4.5 Store data in the cache (data will expire in 10 seconds) Data from the cache: object(stdClass)#3 (2) { ["str_attr"]=> string(4) "test" ["int_attr"]=> int(123) }
means that our Memcached is running normally! :~>
If the above address cannot be downloaded, you can download it at http://www.splinedancer.com/memcached-win32/