Installing Memcache
Yum Install memcached
Installing the Libmemcached Library
Yum Install libmemcached
PHP Installation Memcache Extensions
[Email protected]] Wget-c http://pecl.php.net/get/memcache-3.0.8. Tgz[root@blog. phpha.com] TAR-ZXVF memcache-3.0.8. Tgz[root@blog. phpha.com] CD memcache-3.0.8[Root@blog. phpha.com]/usr/local/php/bin/Phpize[root@blog. phpha.com]./configure-with-php-config=/usr/bin/php-config-with-zlib-Dir[root@blog. phpha.com] Make &&Make Install#Installing shared extensions:/usr/lib64/php/modules/#/usr/lib64/php/modules/memcache.so[[email protected]] vim/etc/php.ini#Extension =/usr/lib64/php/modules/memcache.so[[email protected]] service PHP-FPM Reload
Start
memcached-d-U root-p 11211
Test:
<?PHP$mem=NewMemcache;$mem->addserver ("localhost", 11211);Echo"Version:".$mem-getversion ();classtestclass{Private $str _attr; Private $int _attr; Public function__construct ($str,$int) { $this->str_attr =$str; $this->int_attr =$int; } Public functionSET_STR ($str) { $this->str_attr =$str; } Public functionSet_int ($int) { $this->int_attr =$int; } Public functionGet_str () {return $this-str_attr; } Public functionGet_int () {return $this-int_attr; }}$test=NewTestClass ("Hell World", 1123);$mem->set ("Key",$test,false, 1000);Var_dump($mem->get ("Key"));$test _array=Array("index_1" = "Hello", "Index_2" and "World");$mem->set ("Array_test",$test _array,false);Var_dump($mem->get ("Array_test"));?>
View Code
Problem:
1. Php-config not Found
Find/-name Php-config
2. ZLIB memcache support requires ZLIB not found
Yum Install Zlib-devel
3.can ' t run as root without the-u switch
Memecached-u Root Start
Reference:
CentOS installs memcache.http://blog.csdn.net/php_boy/article/details/6880488 for PHP
CentOS Environment PHP installation memcache extension. http://blog.phpha.com/archives/1554.html
CentOS Installation memcache.http://www.cnblogs.com/wubaiqing/archive/2011/09/19/2181602.html
CentOS Environment PHP installation memcache extension