Install the Memcached extension of PHP on Windows

Source: Internet
Author: User
Download the MemcachedWin32 installation program, http://code.jellycan.com/memcacheddirectly download win32's exe file, click here

1. install Memcached

1. download the Memcached Win32 installation program. Click here to download the win32's exe file from http://code.jellycan.com/memcached.

2. decompress the downloaded zip package to a directory, such as (E: \ iisweb \ memcached.exe), which should be a memcache.exe file.

3. run the CMD command prompt window. note: If your system is Windows 7, you need to run it as an administrator. And enter the memcache.exe directory. Run the following command to install the SDK.

Memcached-d install

4. start the memcached service.

Memcached-d start

5. run the following command to check whether memcached is successfully installed and running.

Wmic process get description, executablepath | findstr memcached.exe
If your installation is successful, memcache.exe and its complete installation path will be displayed. For example

II. install PHP Memcache extension (php_memcache.dll)

1. if your PHP extension directory does not have the dynamic link library file php_memcache.dll, click here to download the correct version.

2. decompress the file and put the php_memcache.dll file into the php extension directory. For example, if I use WampServer, My php extension directory address is E: \ wamp \ bin \ php \ php5.3.3 \ ext.

3. edit php. ini and add the following line of code to the php. ini file.

Extension = php_memcache.dll

If you use WampServer, you can restart all services through the WampServer control menu. If it is iis, restart iis. Now, the Memcached extension has been installed. Now we can use an example in the php Manual to test whether php can use the Memcached service correctly. The test code is as follows:

  1. $ Memcache = new Memcache;
  2. $ Memcache-> connect ('localhost', 11211) or die ("cocould not connect ");
  3. $ Version = $ memcache-> getVersion ();
  4. Echo "Server's version:". $ version ."
    \ N ";
  5. $ Tmp_object = new stdClass;
  6. $ Tmp_object-> str_attr = 'test ';
  7. $ Tmp_object-> int_attr = 123;
  8. $ Memcache-> set ('key', $ tmp_object, false, 10) or die ("Failed to save data at the server ");
  9. Echo "Store data in the cache (data will expire in 10 seconds)
    \ N ";
  10. $ Get_result = $ memcache-> get ('key ');
  11. Echo "Data from the cache:
    \ N ";
  12. Var_dump ($ get_result );

The results are as follows: (php can work with memcached)

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.