本篇內(nèi)容主要講解“怎樣在Linux下給PHP安裝amqp擴(kuò)展”,感興趣的朋友不妨來(lái)看看。本文介紹的方法操作簡(jiǎn)單快捷,實(shí)用性強(qiáng)。下面就讓小編來(lái)帶大家學(xué)習(xí)“怎樣在Linux下給PHP安裝amqp擴(kuò)展”吧!
創(chuàng)新互聯(lián)成立與2013年,先為馬尾等服務(wù)建站,馬尾等地企業(yè),進(jìn)行企業(yè)商務(wù)咨詢(xún)服務(wù)。為馬尾企業(yè)網(wǎng)站制作PC+手機(jī)+微官網(wǎng)三網(wǎng)同步一站式服務(wù)解決您的所有建站問(wèn)題。
怎樣在Linux下給PHP安裝amqp擴(kuò)展
安裝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擴(kuò)展
#下載最新的amqp擴(kuò)展
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擴(kuò)展:
extension=amqp.so
安裝amqp擴(kuò)展會(huì)遇到哪些問(wèn)題
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
其他系統(tǒng)類(lèi)似
使用
//配置信息
$conn_args=array(
'host'=>'127.0.0.1',
'port'=>'5672',
'login'=>'guest',
'password'=>'guest',
'vhost'=>'/'
);
//創(chuàng)建連接
$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"),
);
//生產(chǎn)者,向RabbitMQ發(fā)送消息
$message=$exchange->publish(json_encode($data),'key');
if(!$message){
echo'Messagenotsent',PHP_EOL;
}else{
echo'Messagesent!',PHP_EOL;
}
//消費(fèi)者
while($envelope=$queue->get(AMQP_AUTOACK)){
echo($envelope->isRedelivery())'Redelivery':'NewMessage';
echoPHP_EOL;
echo$envelope->getBody(),PHP_EOL;
}
>
到此,相信大家對(duì)“怎樣在Linux下給PHP安裝amqp擴(kuò)展”有了更深的了解,不妨來(lái)實(shí)際操作一番吧!這里是創(chuàng)新互聯(lián)網(wǎng)站,更多相關(guān)內(nèi)容可以進(jìn)入相關(guān)頻道進(jìn)行查詢(xún),關(guān)注我們,繼續(xù)學(xué)習(xí)!