1. install libmemcached Library yuminstalllibmemcached2. download and decompress the memcache file wgethttp: // pecl.php.net/get/memcache-3.0.8.tgzta
1. install the libmemcached Library
Yum install libmemcached
2. download and decompress the memcache file
Wget http://pecl.php.net/get/memcache-3.0.8.tgz
Tar xzvf memcache-3.0.8.tgz
Cd memcache-3.0.8
3. run the phpize extension installer. assume that the phpzie path is/usr/local/php/bin/phpize. the specific path must be modified according to your environment.
[Root @ nagw.memcache-3.0.8] #/usr/local/php/bin/phpize
Processing ING:
PHP Api Version: 20100412
Zend Module Api No: 20100525
Zend Extension Api No: 220100525
4. start installing extended memcache
[Root @ nag1_memcache-3.0.8] #./configure -- enable-memcache \
-- With-php-config =/usr/local/php/bin/php-config -- with-zlib-dir \
Make & make install
Prompt after installation is complete
Build complete.
Don't forget to run 'Make test '.
Installing shared extensions:/usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/
5. modify the php. ini file and add the following code before zend.
Vim/usr/local/php/lib/php. ini
Extension =/usr/local/php/lib/php/extension/ no-debug-non-zts-20100525/memcache. so
6. restart php-fpm.
Kill-QUIT pid
/Usr/local/php/sbin/php-fpm
7. You can view memcached information through phpinfo ().
8. start memecached.
./Memcached-d-m 100-l 192.168.1.120-p 11211-u root
9. test
With the php memcache test code:
$ Mem = new Memcache;
$ Mem-> connect ("192.168.1.120", 11211) or die ("cocould not connect ");
$ Version = $ mem-> getVersion ();
Echo "Server's version:". $ version ."
\ N ";
$ Mem-> set ('hellokey', 'Hello World', 0,600) or die ("Failed to save data at the memcached server ");
Echo "Store data in the cache (data will expire in 600 seconds)
\ N ";
$ Get_result = $ mem-> get ('hellokey ');
Echo "$ get_result is from memcached server .";
?>
View hit results
Telnet 192.168.1.12011211
Enter the command: status