本文共 2736 字,大约阅读时间需要 9 分钟。
之前介绍了,ubuntu下阿里云官方暂未提供相关帮助文档,ubuntu下模块名称不尽相同,所以本文介绍一下ubuntu12.04下如何配置环境来支持ocs服务,主要是sasl的配置
以下操作均为阿里云服务器操作实录
首先,还是先配置一下高大上的阿里云镜像源
1 | vim /etc/apt/ source .list |
在最前面添加一下内容
01 | deb http://mirrors.aliyun.com/ubuntu/ precise main restricted universe multiverse |
02 | deb http://mirrors.aliyun.com/ubuntu/ precise-security main restricted universe multiverse |
03 | deb http://mirrors.aliyun.com/ubuntu/ precise-updates main restricted universe multiverse |
04 | deb http://mirrors.aliyun.com/ubuntu/ precise-proposed main restricted universe multiverse |
05 | deb http://mirrors.aliyun.com/ubuntu/ precise-backports main restricted universe multiverse |
06 | deb-src http://mirrors.aliyun.com/ubuntu/ precise main restricted universe multiverse |
07 | deb-src http://mirrors.aliyun.com/ubuntu/ precise-security main restricted universe multiverse |
08 | deb-src http://mirrors.aliyun.com/ubuntu/ precise-updates main restricted universe multiverse |
09 | deb-src http://mirrors.aliyun.com/ubuntu/ precise-proposed main restricted universe multiverse |
10 | deb-src http://mirrors.aliyun.com/ubuntu/ precise-backports main restricted universe multiverse |
12 | apt-get update //更新一下列表 |
然后通过ape-get配置GCC,G++
2 | apt-get install build-essential |
然后安装一下php5,php5-dev
1 | apt-get install php5 php5-dev //同时会自动安装php5-cli和php5-common |
安装配置sasl支持
1 | apt-get install libsasl2-dev cloog-ppl |
安装指定版本的libmemcache
1 | wget https://launchpad.net/libmemcached/1.0/1.0.16/+download/libmemcached-1.0.16. tar .gz |
2 | tar -zxvf libmemcached-1.0.16. tar .gz |
3 | cd libmemcached-1.0.16/ |
4 | ./configure --prefix=/usr/ local /libmemcached |
5 | make ; make install ; make clean //这里会有点慢,可以去个洗手间之类的~ |
安装指定版本的memcached
2 | wget http://pecl.php.net/get/memcached-2.1.0.tgz |
3 | tar zxvf memcached-2.1.0.tgz |
6 | ./configure --with-libmemcached- dir =/usr/ local /libmemcached -- enable -memcached-sasl |
7 | make ; make install ; make clean |
配置php支持memcache,然后测试
1 | echo "extension=memcached.so" >>/etc/php5/conf.d/pdo.ini |
3 | root@AY1212111202285f63122:/ |
ok,配置完毕,开始测试
02 | $connect = new Memcached; |
03 | $connect ->setOption(Memcached::OPT_COMPRESSION, false); |
04 | $connect ->setOption(Memcached::OPT_BINARY_PROTOCOL, true); |
05 | $connect ->addServer( '7d9cfd3014aa11e3.m.cnhzalicm10pub001.ocs.aliyuncs.com' , 11211); |
06 | $connect ->setSaslAuthData( '7d9cfd3014aa11e3' , '******' ); |
07 | for ( $i =0; $i <10; $i ++){ $connect ->set( "$i" , "world" ); |
08 | echo "key" . $i . "is:" , $connect ->get( "$i" )." |
02 | root@AY1212111202285f63122:/var/www |
配置完毕
转载地址:http://odzoa.baihongyu.com/