怎样在Linux下给PHP安装amqp扩展-创新互联
本篇内容主要讲解“怎样在Linux下给PHP安装amqp扩展”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“怎样在Linux下给PHP安装amqp扩展”吧!
创新互联建站2013年至今,是专业互联网技术服务公司,拥有项目成都网站设计、网站制作网站策划,项目实施与项目整合能力。我们以让每一个梦想脱颖而出为使命,1280元二连浩特做网站,已为上家服务,为二连浩特各地企业和个人服务,联系电话:18980820575怎样在Linux下给PHP安装amqp扩展
安装librabbitmq-c和rabbitmq-codegen
#下载0-9-1版的rabbitmq-c
gitclonegit://github.com/alanxz/rabbitmq-c.git
cdrabbitmq-c
#Enableandupdatethecodegengitsubmodule
gitsubmoduleinit
gitsubmoduleupdate
#Configure,compileandinstall
autoreconf-i&&./configure&&make&&sudomakeinstall
安装pecl扩展
#下载新的amqp扩展
wgethttp://pecl.php.net/get/amqp-1.0.9.tgz
tarxvzfamqp-1.0.9.tgz
cdamqp-1.0.9&&phpize
./configure--with-amqp&&make&&sudomakeinstall
记得在php.ini中加入amqp扩展:
extension=amqp.so
安装amqp扩展会遇到哪些问题
1、缺少libtool包
configure.ac:installing./install-sh
configure.ac:installing./missing
configure.ac:34:installing./config.guess
configure.ac:34:installing./config.sub
Makefile.am:3:LibtoollibraryusedbutLIBTOOLisundefined
Makefile.am:3:
Makefile.am:3:TheusualwaytodefineLIBTOOListoaddAC_PROG_LIBTOOL
Makefile.am:3:toconfigure.acandrunaclocalandautoconfagain.
Makefile.am:CobjectsinsubdirbutAM_PROG_CC_C_Onotinconfigure.ac
Makefile.am:installing./compile
Makefile.am:installing./depcomp
autoreconf:automakefailedwithexitstatus:1
解决办法,安装libtool,ubuntu:
sudoapt-getinstalllibtool
其他系统类似
使用
//配置信息
$conn_args=array(
'host'=>'127.0.0.1',
'port'=>'5672',
'login'=>'guest',
'password'=>'guest',
'vhost'=>'/'
);
//创建连接
$conn=newAMQPConnection($conn_args);
if(!$conn->connect()){
die('Notconnected:('.PHP_EOL);
}
//OpenChannel
$channel=newAMQPChannel($conn);
//Declareexchange
$exchange=newAMQPExchange($channel);
$exchange->setName('extest');
$exchange->setType('fanout');
$exchange->declare();
//CreateQueue
$queue=newAMQPQueue($channel);
$queue->setName('qutest');
$queue->declare();
//Binditontheexchangetorouting.key
$exchange->bind('qutest','routing.key');
$data=array(
'Name'=>'foobar',
'Args'=>array("0","1","2","3"),
);
//生产者,向RabbitMQ发送消息
$message=$exchange->publish(json_encode($data),'key');
if(!$message){
echo'Messagenotsent',PHP_EOL;
}else{
echo'Messagesent!',PHP_EOL;
}
//消费者
while($envelope=$queue->get(AMQP_AUTOACK)){
echo($envelope->isRedelivery())'Redelivery':'NewMessage';
echoPHP_EOL;
echo$envelope->getBody(),PHP_EOL;
}
>
到此,相信大家对“怎样在Linux下给PHP安装amqp扩展”有了更深的了解,不妨来实际操作一番吧!这里是创新互联建站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!
分享题目:怎样在Linux下给PHP安装amqp扩展-创新互联
URL地址:http://azwzsj.com/article/cdshjo.html