下文小编来为各位介绍阿里云ubuntu OCS安装memcache+php5教程,希望下文可以帮助到各位朋友.
阿里云ubuntu OCS在已装memcache下的安装部骤如下:
1.apt-get 安装 php5-dev libsasl2-dev cloog-ppl
sudo apt-get install php5-dev libsasl2-dev cloog-ppl
2.安装libmemcached(必须是如下版本)
- wget https://launchpad.net/libmemcached/1.0/1.0.16/+download/libmemcached-1.0.16.tar.gz
- tar zxvf libmemcached-1.0.16.tar.gz
- cd libmemcached-1.0.16
- ./configure --prefix=/usr/local/libmemcached
- make; make install; make clean
- cd ..
3.安装过程memcached(必须是如下版本)
- wget http://pecl.php.net/get/memcached-2.1.0.tgz
- tar zxvf memcached-2.1.0.tgz
- cd memcached-2.1.0
- phpize5
- ./configure --with-libmemcached-dir=/usr/local/libmemcached --enable-memcached-sasl
- make; make install; make clean
4.配置php支持memcache
- echo "extension=memcached.so" >>/etc/php5/conf.d/pdo.ini
- echo "memcached.use_sasl = 1" >>/etc/php5/conf.d/pdo.ini
5.查看是否安装成功
php -m |grep mem
6.重启apache
service apache2 restart
7.测试
- $connect = new Memcached;
- $connect->setOption(Memcached::OPT_COMPRESSION, false);
- $connect->setOption(Memcached::OPT_BINARY_PROTOCOL, true);
- $connect->addServer('host', port);
- $connect->setSaslAuthData('username', 'password');
- $connect->set("hello", "world");
- echo 'hello: ',$connect->get("hello");
- $connect->quit(); //Vevb.com
新闻热点
疑难解答