linux php amqp,Linux下给PHP安装amqp扩展 linux 安装php7 php安装 centos php安

本文介绍了在Linux下给PHP安装amqp扩展的过程,有需要的朋友可以关注一下。

安装librabbitmq-c和rabbitmq-codegen# 下载0-9-1版的rabbitmq-c

git clone git://github.com/alanxz/rabbitmq-c.git

cd rabbitmq-c

# Enable and update the codegen git submodule

git submodule init

git submodule update

# Configure, compile and install

autoreconf -i && ./configure && make && sudo make install

安装pecl扩展#下载最新的amqp扩展

wget http://pecl.php.net/get/amqp-1.0.9.tgz

tar xvzf amqp-1.0.9.tgz

cd amqp-1.0.9 && phpize

./configure --with-amqp && make && sudo make install

记得在php.ini中加入amqp扩展:extension=amqp.so

安装过程中可能会遇到的问题

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: Libtool library used but LIBTOOL is undefined

Makefile.am:3:

Makefile.am:3: The usual way to define LIBTOOL is to add AC_PROG_LIBTOOL

Makefile.am:3: to configure.ac and run aclocal and autoconf again.

Makefile.am: C objects in subdir but AM_PROG_CC_C_O not in configure.ac

Makefile.am: installing ./compile

Makefile.am: installing ./depcomp

autoreconf: automake failed with exit status: 1

解决办法,安装libtool,ubuntu:sudo apt-get install libtool

其他系统类似

2、如果还有其他问题,欢迎给我留言,我补上

使用'127.0.0.1',

'port' => '5672',

'login' => 'guest',

'password' => 'guest',

'vhost'=>'/'

);

//创建连接

$conn = new AMQPConnection($conn_args);

if (!$conn->connect()) {

die('Not connected

icon_sad.gif ' . PHP_EOL);

}

// Open Channel

$channel = new AMQPChannel($conn);

// Declare exchange

$exchange = new AMQPExchange($channel);

$exchange->setName('extest');

$exchange->setType('fanout');

$exchange->declare();

// Create Queue

$queue = new AMQPQueue($channel);

$queue->setName('qutest');

$queue->declare();

// Bind it on the exchange to routing.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 'Message not sent', PHP_EOL;

} else {

echo 'Message sent!', PHP_EOL;

}

//消费者

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

echo ($envelope->isRedelivery()) ? 'Redelivery' : 'New Message';

echo PHP_EOL;

echo $envelope->getBody(), PHP_EOL;

}

?>

以上就介绍了Linux下给PHP安装amqp扩展,包括了Linux,php安装方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

声明:本文原创发布php中文网,转载请注明出处,感谢您的尊重!如有疑问,请联系admin@php.cn处理

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值