Install memcache extension in CentOS PHP
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:
<? Php
$ Mem = new Memcache;
$ Mem-> connect ("192.168.1.120", 11211) or die ("cocould not connect ");
$ Version = $ mem-> getVersion ();
Echo "Server's version:". $ version. "<br/> \ 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) <br/> \ 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