ubuntu下手动安装php-amqp模块教程

用于ubuntu的默认源里面没有php5-amqp这个包,所以要用上amqp得考手动编译。

首先安装必须的php编译工具

sudo apt-get install php5-dev

安装rabbitmq的库

sudo apt-get install librabbitmq-dev

如果你的Linux发行版没有现成的librabbitmq-dev包,那么可以通过下载源码编译安装
然后如果你没有安装git话请安装一下git,因为我们要从官方的版本库中获取源代码
# 克隆源码并编译

git clone git://github.com/alanxz/rabbitmq-c.git
cd rabbitmq-c
git submodule init
git submodule update

# 编译库

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

然后我们需要去下载php扩展的源代码,地址在此: http://pecl.php.net/package/amqp

当前最新版本为1.0.10

wget http://pecl.php.net/get/amqp-1.0.10.tgz
tar zxf amqp-1.0.10.tgz
cd amqp-1.0.10/
phpize && ./configure --with-amqp && make && sudo make install
如果报错

/root/amqp-1.0.9/amqp_queue.c: In function ‘read_message_from_channel’:
/root/amqp-1.0.9/amqp_queue.c:341:11: error: ‘AMQP_FIELD_KIND_U64’ undeclared (first use in this function)
/root/amqp-1.0.9/amqp_queue.c:341:11: note: each undeclared identifier is reported only once for each function it appears in
/root/amqp-1.0.9/amqp_queue.c: In function ‘zim_amqp_queue_class_nack’:
/root/amqp-1.0.9/amqp_queue.c:1093:2: error: unknown type name ‘amqp_basic_nack_t’
/root/amqp-1.0.9/amqp_queue.c:1113:3: error: request for member ‘delivery_tag’ in something not a structure or union
/root/amqp-1.0.9/amqp_queue.c:1114:3: error: request for member ‘multiple’ in something not a structure or union
/root/amqp-1.0.9/amqp_queue.c:1115:3: error: request for member ‘requeue’ in something not a structure or union
/root/amqp-1.0.9/amqp_queue.c:1120:3: error: ‘AMQP_BASIC_NACK_METHOD’ undeclared (first use in this function)
make: *** [amqp_queue.lo] Error 1

是因为默认的librabbitmq-dev发行版的包比较旧,用上面git方式编译安装最新即可。

最后一步创建配置文件

sudo echo "extension = amqp.so" > /etc/php5/conf.d/amqp.ini

重启web服务器在phpinfo页面中看到以下内容说明安装好了




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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值