Steps for installing memcached in Windows

Source: Internet
Author: User

(In fact, it is relatively simple to install in Windows)

Source code package preparation:

1, memcached 1.2.1 for Win32 Binaries

This is the latest version of memcached on the Win32 server. You can download it directly;

2. php_memcache-5.2-win32-vc6-x86-20090408.zip

This is the PECL extension required by PHP, that is, the php_memcache extension. (it must be the same as your PHP version. I use 5.2.1)

With the source code package, let's get started. follow the steps below.

1. decompress the first package and put it under a certain disk, for example, in c: \ memcached
2. Enter 'C: \ memcached \ memcached.exe-D install' on the terminal (that is, the CMD command interface) to install
3. Enter 'C: \ memcached \ memcached.exe-D start' to start. (Note: in the future, memcached will be automatically started every time it is started on Windows. In this way, the server has been installed)
4. decompress the second package and there will be only one php_memcache.dll file in usr/local/PhP5/EXT /.
5. in C: \ WINDOWS \ PHP. INI adds a line 'extension = php_memcache.dll '(I don't know why PHP has two configuration files, one in usr/local/PhP5/PHP. INI, and the other is in C:/Windows/, and only changing the previous configuration file does not work, so the PHP. INI is also changed !)

6. Add the following in the PHP. ini file:

CopyCode The Code is as follows: [memcache]
Memcache. allow_failover = 1
Memcache. max_failover_attempts = 20
Memcache. chunk_size = 8192
Memcache. default_port = 11211

It is best to put it under "extension = php_memcache.dll" just now. (This is the default configuration)
6. Restart Apache and check phpinfo. If memcache instructions are available, the installation is successful!

Trial run:

Write an example. php file: (for more usage instructions, refer to the memcache functions instructions in the PHP manual)Copy codeThe Code is as follows:

<? PHP

$ Memcache = new memcache;
$ Memcache-> connect ('localhost', 11211) or die ("cocould not connect ");

$ Version = $ memcache-> getversion ();
Echo "server's version:". $ version. "<br/> \ 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) <br/> \ n ";

$ Get_result = $ memcache-> get ('key ');
Echo "data from the cache: <br/> \ n ";

Var_dump ($ get_result );

?>

If there is output:Copy codeThe 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 )}

It indicates that our memcached is running normally! : ~>

If the preceding address cannot be downloaded, go to http://www.splinedancer.com/memcached-win32/to download it.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.