sudo wget http://pecl.php.net/get/memcache-2.2.1.tgz
sudo tar vxzf memcache-2.2.1.tgz
cd memcache-2.2.1/
sudo /opt/lampp/bin/phpize
./configure --with-php-config=/opt/lampp/bin/php-config --enable-memcache
#make
#make install
(会显示编译好了memcache.so,并安装到了
Build complete.
Don't forget to run 'make test'.
root@hdp003:/home/cchunDownload/memcache-2.2.1# make install
Installing shared extensions: /opt/lampp/lib/php/extensions/no-debug-non-zts-20121212/
)
如果显示错误:
cd /usr/src/
sudo wget http://ftp.gnu.org/gnu/m4/m4-1.4.9.tar.gz
sudo tar -zxvf m4-1.4.9.tar.gz
cd m4-1.4.9/
./configure && make && make install
wget http://ftp.gnu.org/gnu/autoconf/autoconf-2.62.tar.gz
# tar -zvxf autoconf-2.62.tar.gz
# cd autoconf-2.62/
# ./configure && make && make
install
如果显示缺少zlib则:
sudo apt-get install zlib1g-dev
配置php.ini 扩展memcache.so即可使用(当然,首先还得有memcache服务器,memcache服务器的安装与启动请直接百度)。
配置yii使用memcache使用:
'mcache'=>array( 'class'=>'system.caching.CMemCache', 'servers'=>array( array( 'host'=>'192.168.1.202', 'port'=>11211 ), ), ), 'session' => array ( 'class'=> 'CCacheHttpSession', 'cookieMode' => 'only', 'cacheID'=>'mcache', 'timeout' => 1200 ),
来源:https://www.cnblogs.com/cchun/p/3712634.html