You are on page 1of 2

How to install Memcached on Xampp on Windows 7 August 26, 2010 by Leonard Austin in Technical For one of my Zend Framework

rk web applications Im going to install memcached. I am currently using file cache however think memcached is a much better way to go. This post is one in a series: Installing Memcached on Windows 7 and Xampp Setting up Memcached Cache in Zend Framework Installing Memcached on Centos 5. Installing Memcached on Xampp and Windows 7 1a. Go to your php.ini file usually located in C:/xampp/php/php.ini find this line: ;extension=php_memcache.dll and replace it with: extension=php_memcache.dll 1b. If you cannot find this line simply add the following line to below where al l the ;extension= lines. extension=php_memcache.dll 2. Add the following to just below the new line [Memcache] memcache.allow_failover = 1 memcache.max_failover_attempts=20 memcache.chunk_size =8192 memcache.default_port = 11211 3. Download the necessary php_memecache.dll file from the following location. http://downloads.php.net/pierre/ For windows 7 I used the following file: http://downloads.php.net/pierre/php_memcache-2.2.6-5.3-vc9-x86.zip 4. Unzip the php_memcache.dll file and put it into your php ext folder. Usually C:/xampp/php/ext/ 5. Download memcached for windows here (make sure its the win32 binary): http://code.jellycan.com/memcached/ 6. Unzip and put the memcache.exe file into a desired directory (e.g. c:/memcach ed/) 7. Open command line in Windows Administrator Mode. Click start, type in Search programs and Files box, wait for the program cmd.exe t o appear, right hand click on the icon and select run as administrator

8. Install the memcache service Type the following into the command line c:\memcached\memcached.exe -d install If you dont get any errors it means its worked. 9. Start memcached Type the following into the command line c:\memcached\memcached.exe -d start, or net start memcached Server 10. Restart Xampp Apache 11. Test Memcache Create a php file and paste the following code. Then go to the page. If you do n ot see any errors then it has worked. <?php $memcache = new Memcache; $memcache->connect(localhost, 11211) or die ("Could not connect"); $version = $memcache->getVersion(); echo "Servers 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); ?> 12. Just in case it doesnt work: One other thing I did was to run the C:/memcache d/memcached.exe file as administrator. This opens the ports on the windows firew all which might solve some problems.

You might also like