Home  >  Article  >  Backend Development  >  Tutorial on installing memcache_PHP under windows system

Tutorial on installing memcache_PHP under windows system

WBOY
WBOYOriginal
2016-07-13 10:31:12835browse

Regarding the introduction of memcache, I won’t go into details here. Readers can refer to: What is memcached? How to use memcache?

(1) To install memcache, first you have to download two files, the memcached installation file and the pecl extension php_memcache.dll file required by php. Since this is an introduction to installing memcached under windows, you need to download memcached. exe. The specific download address of memcached.exe is: http://code.jellycan.com/memcached/. On this page, you have to download the file named memcached-1.2.6-win32-bin.zip. As for php_memcache.dll, the download address is not provided here. Search it on Baidu yourself, because it must be the same as your own PHP version (the download address of several more common php_memcache.dll versions is listed below).

(2) After the above required tools are prepared, you can start installation and debugging. First install memcache.

Extract the downloaded memcache file package and put it in a certain disk, such as c:memcached

Enter "c:memcachedmemcached.exe -d install" in the terminal (cmd command interface) to install

At this time, you may not know what port the memcache you installed uses. Next, modify the port to the port we specified by modifying the registry. Open the registry editor, find HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesmemcached Server, find an ImagePath string item below, double-click the string, append -l 127.0.0.1 -m 45 -p 51321 after the item value (the meaning here is that the access IP is: 127.0.0.1 uses 45M memory, 51321 is the port), close the registry editor after modification.

Then enter in the command interface: "c:memcachedmemcached.exe -d start" to start the memcache service or find the memcached service in the computer service item and restart it.

After the above operations are completed, let us check whether the cache service memcache is successfully installed and running. Continue to enter: "telnet 127.0.0.1 51321" in the terminal. What may happen after the input is completed? Then enter stats. If a bunch of understandable or unintelligible English similar to the following appears, it means that the memcache service has been successfully installed and run. .

STAT pid 5636
STAT uptime 936
STAT time 1344915126
STAT version 1.2.6
STAT pointer_size 32
STAT curr_items 0
STAT total_items 0
STAT bytes 0
STAT curr_connections 2
STAT total_connections 3
STAT connection_structures 3
STAT cmd_get 0
STAT cmd_set 0
STAT get_hits 0
STAT get_misses 0
STAT evictions 0
STAT bytes_read 19
STAT bytes_written 7
STAT limit_maxbytes 67108864
STAT threads 1
END

Note: If your system is Win 7, you may get a message similar to "'telnet' is not an internal or external command, nor is it an operable program." After investigation, this is because Win7 does not have the telnet function installed by default. So you can't use the telnet command directly. You can go to "Control Panel"--"Programs"---"Turn Windows features on or off" and check "telnet client".

(3) Configure PHP. Unzip the downloaded pecl module package and put php_memache.dll in the ext directory of the php directory (tip: in order to prevent some unexpected errors, it is best to download the module package that is consistent with the php version). Then find the php.ini file, add a line in it: extension=php_memcache.dll, and then restart the apache server. At this point, the memcache extension package of php has been installed.

(4) Test whether memcache can work in PHP environment. We can use the following piece of code to test:

$memcache_obj = new Memcache;
$memcache_obj->connect('127.0.0.1', 51321); 
$memcache_obj->set('var_key', 'memcache 测试!',MEMCACHE_COMPRESSED, 50);
echo $memcache_obj->get('var_key');

If "memcache test!" is output normally, it means that you have successfully set up the memcache service for your PHP environment. Note that errors such as "Class 'Memcache' not found in..." may be reported here. This has been tested and is caused by the inconsistency between the expansion package and your PHP environment. Please re-download an expansion package that is consistent with your PHP environment. That's it.

Articles you may be interested in

  • Installation and configuration tutorial of memcache under windows
  • Installation and use of Sphinx under windows [Supports Chinese full-text search]
  • Sharing of Windows 7 system optimization and acceleration methods
  • How to run PHP files under the command line under windows
  • Master-slave synchronization backup steps of mysql database in windows environment
  • Detailed explanation of the difference between window.navigate and window.location.href
  • How to install and configure the PHP running environment under Windows 7
  • Win7 system slimming optimization

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/764133.htmlTechArticleI won’t say more about the introduction of memcache here. Readers can refer to: What is memcached? How to use memcache? (1) To install memcache, you must first download two files, memca...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn