作者在 2014-03-21 14:21:17 发布以下内容
yum install ntsysv mysql mysql-server git-core gcc gcc-c++ libxml2 libxml2-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libmcrypt libmcrypt-devel openssl openssl-devel pcre-devel libevent
#先安装libmemcached https://launchpad.net/libmemcached/+download
cd; \
wget https://launchpad.net/libmemcached/1.0/1.0.18/+download/libmemcached-1.0.18.tar.gz; \
tar zxvf libmemcached*; \
cd libmemcached*; \
./configure; \
make; \
make install;
#安装php的igbinary扩展 http://pecl.php.net/package/igbinary
cd; \
wget http://pecl.php.net/get/igbinary-1.1.1.tgz; \
tar zxvf igbinary*; \
cd igbinary*; \
/usr/local/php/bin/phpize; \
./configure --with-php-config=/usr/local/php/bin/php-config; \
make; \
make install; \
mv /usr/local/php/lib/php/extensions/*/igbinary.so /usr/local/php/lib/php/extensions/;
vi /usr/local/php/etc/php.ini;
#添加一行
extension=igbinary.so
#退出vim
#安装MEMCACHED扩展正式开始
cd; \
wget http://pecl.php.net/get/memcached-2.1.0.tgz; \
tar zxvf memcached*; \
cd memcached*; \
/usr/local/php/bin/phpize; \
./configure --enable-memcached-igbinary --enable-memcached-json --with-php-config=/usr/local/php/bin/php-config --with-zlib-dir; \
make; \
make install; \
mv /usr/local/php/lib/php/extensions/*/memcached.so /usr/local/php/lib/php/extensions/;
vi /usr/local/php/etc/php.ini;
#添加一行
extension=memcached.so
#退出vim
kill -USR2 `cat /usr/local/php/var/run/php-fpm.pid` #重启php-fpm
<?php
$m = new Memcached();
$m->addServer('127.0.0.1', 11211);
$m->set('foo', 'This is from memcached');
echo $m->get('foo');