ubuntu 12.04 apt-get安装配置阿里云OCS的php支持

本文介绍如何在Ubuntu 12.04上配置环境以支持OCS服务,包括配置阿里云镜像源、安装GCC/G++、PHP5及其开发工具包、libsasl2-dev、指定版本的libmemcache和memcached,以及最终测试memcache支持。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

之前介绍了centos/redhat下如何配置ocs的PHP环境支持,ubuntu下阿里云官方暂未提供相关帮助文档,ubuntu下模块名称不尽相同,所以本文介绍一下ubuntu12.04下如何配置环境来支持ocs服务,主要是sasl的配置
以下操作均为阿里云服务器操作实录

首先,还是先配置一下高大上的阿里云镜像源

1 vim /etc/apt/source.list

在最前面添加一下内容

01deb http://mirrors.aliyun.com/ubuntu/ precise main restricted universe multiverse
02deb http://mirrors.aliyun.com/ubuntu/ precise-security main restricted universe multiverse
03deb http://mirrors.aliyun.com/ubuntu/ precise-updates main restricted universe multiverse
04deb http://mirrors.aliyun.com/ubuntu/ precise-proposed main restricted universe multiverse
05deb http://mirrors.aliyun.com/ubuntu/ precise-backports main restricted universe multiverse
06deb-src http://mirrors.aliyun.com/ubuntu/ precise main restricted universe multiverse
07deb-src http://mirrors.aliyun.com/ubuntu/ precise-security main restricted universe multiverse
08deb-src http://mirrors.aliyun.com/ubuntu/ precise-updates main restricted universe multiverse
09deb-src http://mirrors.aliyun.com/ubuntu/ precise-proposed main restricted universe multiverse
10deb-src http://mirrors.aliyun.com/ubuntu/ precise-backports main restricted universe multiverse
11 
12apt-get update //更新一下列表

然后通过ape-get配置GCC,G++

1apt-get build-dep gcc
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

1 cd..
2wget http://pecl.php.net/get/memcached-2.1.0.tgz
3 tar zxvf memcached-2.1.0.tgz
4 cd memcached-2.1.0
5phpize5
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
2 
3 root@AY1212111202285f63122:/# php -m |grep mem
4memcached

ok,配置完毕,开始测试

1vim /var/www/ocs.php
01< ?php
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")."
09";
10}
11 $connect->quit();
12?>
01php ocs.php
02 root@AY1212111202285f63122:/var/www# php ocs.php
03key0is:world
04key1is:world
05key2is:world
06key3is:world
07key4is:world
08key5is:world
09key6is:world
10key7is:world
11key8is:world
12key9is:world

配置完毕

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值