Instructions for installing memcached under Windows _php tips

Source: Internet
Author: User
Tags memcached unpack win32

(In fact, the installation is relatively simple under windows)

SOURCE Package Preparation:

1,memcached 1.2.1 for Win32 binaries

This is the WIN32 server side of the latest version of memcached, direct download on it;

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

This is the PECL extension that PHP needs, that is, the php_memcache extension; (be sure to be the same as your PHP version, I'm using 5.2.1)

With the source package, then start the feast, follow the steps below

1. Unpack the first package under a disk, such as in c:\memcached
2. Enter ' c:\memcached\memcached.exe-d install ' installation at terminal (also known as cmd Command interface)
3. Re-enter: ' c:\memcached\memcached.exe-d start ' start. (Note: Later memcached will automatically start as a service for Windows each time it is powered on.) So the server side is already installed.
4. Unpack the second package, there will be only one php_memcache.dll file, put it into the usr/local/php5/ext/
5. Add a line of ' Extension=php_memcache.dll ' to C:\WINDOWS\php.ini (don't know why PHP has two profiles, one in Usr/local/php5/php.ini and the other in c:/ windows/, and only to change the previous configuration file does not work, so the WINDOWS php.ini also changed! )

6, then add in the php.ini file:

Copy Code code as follows:

[Memcache]
Memcache.allow_failover = 1
Memcache.max_failover_attempts=20
Memcache.chunk_size =8192
Memcache.default_port = 11211

It's best to put it under the "Extension=php_memcache.dll" that you just wrote. (This is some of the default configurations)
6. Restart Apache, and then look at the phpinfo, if there are memcache instructions, then the installation is successful!

Trial run:

Write a example.php file: (See the PHP Manual for Memcache functions instructions for more use)
Copy Code code as follows:


<?php

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

$version = $memcache->getversion ();
echo "Server" version: ". $version." <br/>\n ";

$tmp _object = new StdClass;
$tmp _object->str_attr = ' Test ';
$tmp _object->int_attr = 123;

$memcache->set (' key ', $tmp _object, False, All) or Die ("Failed to save data at the server");
echo "Store data in the cache" (data would expire in seconds) <br/>\n ";

$get _result = $memcache->get (' key ');
echo "Data from the cache:<br/>\n";

Var_dump ($get _result);

?>

If there is output:
Copy Code code as follows:

Server ' s version:1.4.5
Store data in the cache (data would expire in seconds)
Data from the cache:
Object (StdClass) #3 (2) {["Str_attr"]=> string (4) "Test" ["Int_attr"]=> int (123)}

It means that our Memcached has been running properly! :~>

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

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.