29

How to install memcache in WAMP?

I don't find any php_memche in php.ini.

What do I do now?

@Ryan

thanks for your step, now memcache enabled in WAMP, i have cross checked in the PHPINFO as well. memcache is displaying.

i have tried below example memcache sample. but throwing error.

<?php

$memcache = new Memcache;
$memcache->connect('localhost:8085', 11211) or die ("Could 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);

?>

Getting below notice error.

( ! ) Notice: Memcache::getversion() [memcache.getversion]: Server localhost:8085 (tcp 11211) failed with: Malformed version string (0) in C:\wamp\www\memcache\sample.php on line 7

What i missed...

Bharanikumar
  • 25,457
  • 50
  • 131
  • 201
  • Probably better answered on serverfault - http://serverfault.com/questions/47950/how-do-you-install-memcache (deals with xampp) might help – gnarf Jun 10 '10 at 17:12

8 Answers8

49

Here are the steps that worked for me:

Needed Files

Steps

  1. Copy MSVCP71.DLL, msvcr71.dll to C:\windows\sysWOW64
  2. Copy memcached.exe into C:\memcached
  3. Click Windows-Key
  4. Type: CMD
  5. press: Ctrl-Shift-Enter
  6. Choose yes
  7. type: C:\memcached\memcached.exe -d install
  8. type: C:\memcached\memcached.exe -d start
  9. Copy php_memcache.dll to C:\wamp\bin\php\php5.3.4\ext
  10. Restart Apache using Wamp controls
  11. Enable WAMP -> PHP -> PHP Extensions -> php_memcache
T.Todua
  • 53,146
  • 19
  • 236
  • 237
Ryan Charmley
  • 1,127
  • 15
  • 18
  • Similar one thread http://pureform.wordpress.com/2008/01/10/installing-memcache-on-windows-for-php/ – Bharanikumar Jan 16 '13 at 13:12
  • 2
    I did all the steps and phpinfo() doesn't have memcache. The list of extensions in wamp shows a warning sign next to memcache. No memcache class in php. – Curtis Aug 26 '14 at 18:49
  • Would it be wise at this point to update the DLL link to something like [this](http://windows.php.net/downloads/pecl/releases/memcache/3.0.8/)?? – Cayce K Jun 30 '15 at 20:13
  • 3
    **Never ever ever download Microsoft Visual C/C++ Runtime libraries like suggested in this answer.** Instead go to the icrosoft site and get then the correct way – RiggsFolly Dec 29 '15 at 19:06
  • The 'Working memcache for PHP 5.3.4' link opened a nasty scam window when accessed with Chrome. The underlying downloaded zip file didn't contain any viruses when scanned but if you're resorting to this then be on your guard. – dartacus Feb 04 '16 at 09:34
  • You might need to add the line 'extension=php_memcache.dll' to php.ini, otherwise WAMP > PHP > Extensions might complain about it. And also need to exit (not restart) from WAMP and start it again. Otherwise extensions menu may not get updated. – Keerthi Bandara Dec 09 '16 at 17:36
  • This is an older answer. Try googling for how to download most of these files / packages. – Webmaster G Oct 11 '18 at 20:07
13

If you are running 64 bit WAMP:

The common service and extensions will not work for you.

Install the 64 bit memcached service:

http://s3.amazonaws.com/downloads.northscale.com/memcached-win64-1.4.4-14.zip

And one of these php extensions (to match your php version):

Php 5.3: http://www.mediafire.com/download.php?o60feet9sw71six

Php 5.4: http://www.mediafire.com/download.php?8d3vd26z3fg6bf1

32bit version for Php 5.4: http://windows.php.net/downloads/pecl/releases/memcache/3.0.6/php_memcache-3.0.6-5.4-ts-vc9-x86.zip

Beachhouse
  • 4,972
  • 3
  • 25
  • 39
  • Enabling the mentioned binary to work as service prompts the windows user that a given software application is requiring attention and one should interact with it. – Nikola Petkanski Sep 02 '13 at 14:14
  • This solution helped me as well. Worth mentioning, I put both of the dll files from memcached-win64-1.4.4-14.zip into C:\Windows\System32 and before I installed memcached I ran cmd prompt as administrator. – Sam Sep 25 '13 at 19:33
  • thanks for the 64 bit memached service hint. Applying it worked for me on wamp x64 + win8 + php 5.4.3. – KarelG Feb 18 '14 at 14:07
  • 2
    Your answer for `5.4 version is worked` but after that need to follow answer of @Idan Magled's 4th step **"Step 4: close and open up your WAMP (not restarting - close and open) and you done."** – Smile May 21 '15 at 10:13
13

I was stuck on this for a while so I decided to write my answer:

Step 1: download the right package that compatible with your PHP version and your wamp version (32bit or 64 bit) from this site:

Link for download site

I suggest you download the "Thread Safe" one.

Step 2: After you downloaded the package, you need to copy the php_memcache.dll in to your extensions folder at: C:\wamp\bin\php\{YOUR PHP VERSION}\ext

Step 3: Add the extensions value to your php.ini file, to do this in the right place just search for another extension that is already installed like: extension=php_bz2.dll and just copy paste it at the end of this sections (after all the "extension=")

extension=php_memcache.dll

Step 4: close and open up your WAMP (not restarting - close and open) and you done.

If you are having trouble now - just open the error log file (in the root directory) and check what is the error that you get there.

My error was that my WAMP was a 32 bit, and i have downloaded 64 bit memcache

This solve my problem, hope its helped.

Idan Magled
  • 2,186
  • 1
  • 23
  • 33
  • 2
    You save my other few hours. I came here after spending 1 hour. Thumbs up, friend! – Smile May 21 '15 at 08:47
  • I know this is quite old but I cannot get my wamp to show the PHP extension under PHP > extensions, any ideas? – SISYN Dec 28 '16 at 22:07
2

to everyone having problems installing memcache for wamp here's how it worked for me.

  1. make sure you check you're phpinfo and look for "Compiler" mine shows MSVC9 (Visual C++ 2008) this is so you know if you download the dll for vc9 or vc6. also look for "Thread Safety" on phpinfo it shows enabled then you need to download the dll file that contains TS if disabled then you download the dll with the words NTS.

below is where you can find the dll's for the diffent php versions make sure the version you download matches you're version:

Make sure also you have 32 bit or 64 bit and you download it correctly

then extract the files into your windows/system32 if you're windows is 32 bit or the system folder for 64 bit on you're windows.

Also extract to you're wamp/bin/apache/bin and wamp/bin/you're_php_version/ext and also memcache.exe extract to this folder make sure you use memcached for 32 or 64 bit according to you're system.

Once you finish this then you run the you're windows command prompt as administrator then browse to the location of you're executable memcache and do the following:

step 1: memcache.exe -d install step 2: memcache.exe -d start

then on you're wampserver open the tray menu and go to the php menu and click php.ini make sure you add on you're extensions in case not listed there: extension=php_memcache.dll

restart you're wampserver and go to you're phpinfo and look for memcache if you see it then it's installed.

hope it helps

happy new year to all!

2

Memcache is a PECL extension and not bundled with PHP. Start with the manual page for installation instructions.

Pekka
  • 442,112
  • 142
  • 972
  • 1,088
0
  1. Download memcache not memcached if you used windows.Download your php version wise (download link:https://pecl.php.net/package/memcache/3.0.8/windows)
  2. Copy php_memcache.dll to C:\wamp\bin\php\php5.3.4\ext
  3. Restart Apache using Wamp controls
  4. Enable WAMP -> PHP -> PHP Extensions -> php_memcache
rowmoin
  • 698
  • 2
  • 8
  • 17
0

Memcache is a PECL extension and not bundled with PHP.

This PECL extension is not bundled with PHP . Information for installing this PECL extension may be found in the manual chapter titled Installation of PECL extensions. Additional information such as new releases, downloads, source files, maintainer information, and a CHANGELOG, can be located here: http://pecl.php.net/package/memcache.

Note:
It's possible to disable memcache session handler support. 
The 'pecl install' option prompts for this (default is enabled) 
however when compiling statically into 
PHP the --disable-memcache-session configure option may be used.

It is very important to note when reading the information supplied by others on this page that there are two distinct memcache PHP implementations for the service "memcached".

1) pecl-memcache
2) pecl-memcached

This page is for the first, pecl-memcache.

If you are looking for pecl-memcached information, visit here:

http://www.php.net/manual/en/book.memcached.php

Pranav MS
  • 2,235
  • 2
  • 23
  • 50
0

Because my edit got rejected, here is what worked for me, as a supplement, after installing memcache on windows:

Manually add the memcache configuration to the php.ini. NOTE: there might be two different php.ini's installed on your system. For me, modifying the one located in wamp64/bin/apache is the only one that worked:

extension=php_memcache.dll
[Memcache]
memcache.allow_failover = 1
memcache.max_failover_attempts=20
memcache.chunk_size =8192
memcache.default_port = 11211

You may need to add the extension to the extension block;

Inspired from this thread.

Gabe Hiemstra
  • 269
  • 1
  • 14