This article mainly solves the window under the memcached installation problem, in the use process often will be mixed with the first step environment configuration, this article combined with my configuration process and the problems encountered, do a summary
1. Open the extension of PHP memcache and modify it in the file D:\xampp\php\php.ini file (if not added)
Extension=php_memcache.dll
2. Add configuration information for Memcache
[Memcache]memcache. allow_failover = 1Memcache. max_failover_attempts=20Memcache. chunk_ Size =8192memcache. Default_port = 11211
The configuration information is explained as follows
memcache.allow_failover = 1memcache.max_failover_attempts=20memcache.chunk_size =8192memcache.default_port = 11211 //
3, download the corresponding version of the Memcache.exe version, this can be first through phpinfo () to get the PHP version of the server, Then choose the corresponding version of Memcache.exe, this is very important, if the version is different, it will cause the configuration to fail, the most likely problem is this place
You can download memcache versions in the following connection
When the download is complete, copy to the php\ext\ directory,
4, start the installation of Memcache.exe, the specific steps are as follows
A, click Start, Search->cmd, then right-click cmd, select "Run as Administrator", enter the Memcache.exe directory, my directory is D:\memcache
b, enter the following command to install
D:/memcached/memcached.exe- D Install
C, there is no error message, indicating that the installation was successful, and then enter the following instructions to open the Memcache service
Memcached.exe-d Start
Or you can start it like this.
net start "memcached Server"
5, at this time, you have installed Memcache.exe, and listen to 11211 ports, by default, the service has only 64MB of memory, we can modify the registry to increase memory
hkey_local_machine/SYSTEM/currentcontrolset/services/memcached Server.
Change the ImagePath to
"C:/memcached/memcached.exe"-D runservice-m 512
6. Test whether the Memcache is installed successfully
Run the following PHP
<?PHP$memcache=NewMemcache ();$memcache->connect (' localhost ', 11211) or die("Could Not Connect");$version=$memcache-getversion ();Echo"Server S version:".$version." <br/>\n ";$tmp _object=NewStdClass;$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 would expire in seconds) <br/>\n";$get _result=$memcache->get (' key ');Echo"Data from the cache:<br/>\n";Var_dump($get _result);?>
View Code
Results
7, common problems encountered
A,memcache the difference between ts,nts, TS refers to thread safety, NTS is non-thread-safe, in phpinfo (), if the Thread_safe is set to Enabled, it is best to choose TS, conversely, select NTS
Basic steps for installing memcache under Windows