溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

怎樣在Linux下給PHP安裝amqp擴(kuò)展

發(fā)布時間:2021-08-09 20:35:49 來源:億速云 閱讀:239 作者:chen 欄目:編程語言

本篇內(nèi)容主要講解“怎樣在Linux下給PHP安裝amqp擴(kuò)展”,感興趣的朋友不妨來看看。本文介紹的方法操作簡單快捷,實用性強。下面就讓小編來帶大家學(xué)習(xí)“怎樣在Linux下給PHP安裝amqp擴(kuò)展”吧!

  怎樣在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ò)展會遇到哪些問題

  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)類似

  使用

  //配置信息

  $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;

  }

  //消費者

  while($envelope=$queue->get(AMQP_AUTOACK)){

  echo($envelope->isRedelivery())'Redelivery':'NewMessage';

  echoPHP_EOL;

  echo$envelope->getBody(),PHP_EOL;

  }

  >

到此,相信大家對“怎樣在Linux下給PHP安裝amqp擴(kuò)展”有了更深的了解,不妨來實際操作一番吧!這里是億速云網(wǎng)站,更多相關(guān)內(nèi)容可以進(jìn)入相關(guān)頻道進(jìn)行查詢,關(guān)注我們,繼續(xù)學(xué)習(xí)!

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI