RabbitMQ 官方提供了三种 PHP 可用的扩展,分别是:

php-amqp

http://code.google.com/p/php-amqp/

php-rabbit

http://code.google.com/p/php-rabbit/

php-amqplib

http://code.google.com/p/php-amqplib/

这里我选择使用 php-rabbit,因为这个项目的 Activity 比较高,名字也比较权威

安装步骤:

下载 RabbitMQ-C 客户端库 librabbitmq:

http://hg.rabbitmq.com/rabbitmq-c/

下载 RabbitMQ 协议代码生成工具:

http://hg.rabbitmq.com/rabbitmq-codegen/

注意 librabbitmq 的版本号,使用最新版本可能会导致下面编译 php-rabbit 时出错:

/bin/sh /work/setup/php-rabbit/libtool –mode=compile cc -I. -I/work/setup/php-rabbit -DPHP_ATOM_INC -I/work/setup/php-rabbit/include -I/work/setup/php-rabbit/main -I/work/setup/php-rabbit -I/usr/local/php/include/php -I/usr/local/php/include/php/main -I/usr/local/php/include/php/TSRM -I/usr/local/php/include/php/Zend -I/usr/local/php/include/php/ext -I/usr/local/php/include/php/ext/date/lib -I/usr/local/include -DHAVE_CONFIG_H -g -O2 -c /work/setup/php-rabbit/rabbit.c -o rabbit.lo

mkdir .libs

cc -I. -I/work/setup/php-rabbit -DPHP_ATOM_INC -I/work/setup/php-rabbit/include -I/work/setup/php-rabbit/main -I/work/setup/php-rabbit -I/usr/local/php/include/php -I/usr/local/php/include/php/main -I/usr/local/php/include/php/TSRM -I/usr/local/php/include/php/Zend -I/usr/local/php/include/php/ext -I/usr/local/php/include/php/ext/date/lib -I/usr/local/include -DHAVE_CONFIG_H -g -O2 -c /work/setup/php-rabbit/rabbit.c -fPIC -DPIC -o .libs/rabbit.o

/work/setup/php-rabbit/rabbit.c: In function ‘zim_rabbit_class___construct’:

/work/setup/php-rabbit/rabbit.c:227: warning: ‘php_std_error_handling’ is deprecated (declared at /usr/local/php/include/php/main/php.h:295)

/work/setup/php-rabbit/rabbit.c:230: warning: ‘php_std_error_handling’ is deprecated (declared at /usr/local/php/include/php/main/php.h:295)

/work/setup/php-rabbit/rabbit.c: In function ‘zim_rabbit_class_isConnected’:

/work/setup/php-rabbit/rabbit.c:329: warning: ‘php_std_error_handling’ is deprecated (declared at /usr/local/php/include/php/main/php.h:295)

/work/setup/php-rabbit/rabbit.c: In function ‘zim_rabbit_queue_class___construct’:

/work/setup/php-rabbit/rabbit.c:363: warning: ‘php_std_error_handling’ is deprecated (declared at /usr/local/php/include/php/main/php.h:295)

/work/setup/php-rabbit/rabbit.c:368: warning: ‘php_std_error_handling’ is deprecated (declared at /usr/local/php/include/php/main/php.h:295)

/work/setup/php-rabbit/rabbit.c: In function ‘zim_rabbit_queue_class_delete’:

/work/setup/php-rabbit/rabbit.c:504: error: unknown field ‘ticket’ specified in initializer

/work/setup/php-rabbit/rabbit.c:512: error: unknown field ‘ticket’ specified in initializer

/work/setup/php-rabbit/rabbit.c: In function ‘zim_rabbit_queue_class_purge’:

/work/setup/php-rabbit/rabbit.c:574: error: unknown field ‘ticket’ specified in initializer

/work/setup/php-rabbit/rabbit.c:580: error: unknown field ‘ticket’ specified in initializer

/work/setup/php-rabbit/rabbit.c: In function ‘zim_rabbit_queue_class_bind’:

/work/setup/php-rabbit/rabbit.c:646: error: unknown field ‘ticket’ specified in initializer

/work/setup/php-rabbit/rabbit.c: In function ‘zim_rabbit_queue_class_unbind’:

/work/setup/php-rabbit/rabbit.c:713: error: unknown field ‘ticket’ specified in initializer

/work/setup/php-rabbit/rabbit.c: In function ‘zim_rabbit_queue_class_consume’:

/work/setup/php-rabbit/rabbit.c:781: error: unknown field ‘ticket’ specified in initializer

/work/setup/php-rabbit/rabbit.c: In function ‘zim_rabbit_queue_class_get’:

/work/setup/php-rabbit/rabbit.c:917: error: unknown field ‘ticket’ specified in initializer

/work/setup/php-rabbit/rabbit.c: In function ‘zim_rabbit_exchange_class___construct’:

/work/setup/php-rabbit/rabbit.c:1169: warning: ‘php_std_error_handling’ is deprecated (declared at /usr/local/php/include/php/main/php.h:295)

/work/setup/php-rabbit/rabbit.c: In function ‘zim_rabbit_exchange_class_delete’:

/work/setup/php-rabbit/rabbit.c:1318: error: unknown field ‘ticket’ specified in initializer

/work/setup/php-rabbit/rabbit.c:1326: error: unknown field ‘ticket’ specified in initializer

/work/setup/php-rabbit/rabbit.c: In function ‘zim_rabbit_exchange_class_bind’:

/work/setup/php-rabbit/rabbit.c:1534: error: unknown field ‘ticket’ specified in initializer

make: *** [rabbit.lo] Error 1

看了下是头文件 /usr/local/include/amqp_framing.h 中的结构体定义与源代码中冲突,因此怀疑是 librabbitmq 版本的问题。

使用 svn 上的代码也不行,很明显当前版本不适用。

看到官方下载页面上的声明:

Specification

The current RabbitMQ server and Java client library releases implement AMQP protocol version 0-8. The .NET/C# client implements AMQP protocol versions 0-8 and 0-9.

估计得用 0.8 版,我使用以下方式安装 librabbitmq 时可以编译通过:

wget http://hg.rabbitmq.com/rabbitmq-c/archive/ce1eaceaee94.tar.gz -O rabbitmq-c.tar.gz

tar zxf rabbitmq-c.tar.gz

wget http://hg.rabbitmq.com/rabbitmq-codegen/archive/c7c5876a05bb.tar.gz -O rabbitmq-codegen.tar.gz

tar zxf rabbitmq-codegen.tar.gz

mv rabbitmq-codegen-c7c5876a05bb/ rabbitmq-c-ce1eaceaee94/codegen

cd rabbitmq-c-ce1eaceaee94/

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

如果提示:

checking finding a python with simplejson installed… configure: error: could not find a python that can ‘import simplejson’

请安装 python 的 simplejson 库:

# wget http://pypi.python.org/packages/source/s/simplejson/simplejson-2.1.1.tar.gz

# tar zxf simplejson-2.1.1.tar.gz

# cd simplejson-2.1.1

# python setup.py install

下载并安装 php-rabbit:

# wget http://php-rabbit.googlecode.com/files/php-rabbit.r91.tar.gz

# tar zxf php-rabbit.r91.tar.gz

# cd php-rabbit

# /usr/local/php/bin/phpize

# ./configure –with-php-config=/usr/local/php/bin/php-config –with-rabbit

# make && make install

修改 php.ini,在尾部加上:

extension = rabbit.so

查看扩展是否安装成功:

# php -m | grep rabbit

rabbit

完工!!

php 安装rabbitmq拓展_安装 php-rabbit: RabbitMQ 的 PHP 扩展相关推荐

  1. php 安装rabbitmq拓展_【RabbitMQ】——centos7安装rabbitmq教程 以及 PHP开启rabbitmq扩展...

    第一步:安装Erlang 因为rabbitMQ是Erlang语言编写的,所以我们首先需要安装Erlang rpm -Uvh http://www.rabbitmq.com/releases/erlan ...

  2. mysql的安装备份恢复_安装使用Percona XtraBackup来备份恢复MySQL的教程

    1.安装XtraBackup yum的安装方法: 自动 $ rpm -Uhv http://www.percona.com/downloads/percona-release/percona-rele ...

  3. 安装mysql总结_安装mysql总结

    第一步: 1,提示安装excel 2010,一直处于死循环中,这时去点安装这个 2,安装到最后,如果失败,看看D:\ProgramData\MySQL\MySQL Server 5.6\data下面的 ...

  4. 计算机连接网络需要什么,宽带怎么安装需要什么_安装宽带步骤-系统城

    我们的电脑能够上网就是因为宽带拨号后连接网络才可以上网,一些朋友了解宽带的安装步骤和需要设备.那么宽带应该怎么安装呢?宽带安装又需要什么呢?接下来小编就给大家宽带的安装步骤和需要设备. 具体如下: 一 ...

  5. python安装docx模块_安装Python的docx模块

    安装Python的docx模块 在执行进行自动化测试的时候,很多时候我们其实不会一直关注这个测试的,很多时候我们只需要关注一个结果,与我们的预期是否相互符合就可以了. 所以我们只需要把预期结果,和实际 ...

  6. micropython安装第三方库_安装第三方模块

    在Python中,安装第三方模块,是通过包管理工具pip完成的. 如果你正在使用Mac或Linux,安装pip本身这个步骤就可以跳过了. 如果你正在使用Windows,请参考安装Python一节的内容 ...

  7. mysql8.0安装无法设置密码_安装mysql8.0.16初步设置密码时候遇到的问题

    遵循网上的教程,安装mysql进行到mysql - u root -p 命令的时候,报错 ① 这时候去网上查解决问题方案,进入cmd先net stop mysql ,停止mysql服务,然后在mysq ...

  8. 安装 并且使用_安装密封圈的注意事项

    在我们的日常生活中,有许多地方都会用到密封圈,密封圈不仅密封性好,其稳定性也优良,密封圈分为:硅胶密封圈.耐高温密封圈和橡胶密封圈等,密封圈在生活中被应用广泛,是需求较多的一款产品.那么,下面就让瑞博 ...

  9. python安装redis模块_安装redis及python redis模块

    第一部分:安装redis mkdir /usr/local/redis cd /usr/local/src wget http://download.redis.io/releases/redis-2 ...

最新文章

  1. easyUI显示echarts
  2. android 开发使用adb操作sqlite
  3. xgboost与gbdt的区别
  4. 严重: StandardServer.await: create[8005]:
  5. tomcat 下catalina.out 日志乱码问题处理
  6. vue2.x 在引用插件的时候,npm run dev跑正常 ,npm run build 报错vue-cli Unexpected token: punc (() [...
  7. svn cvs git的区别
  8. 深度学习修炼(三)——自动求导机制
  9. app android de,Android Deobfuscation
  10. O(V*n)的多重背包问题
  11. qt ui界面无法移动控件_都是知识点!移动端UI设计最基本的10种APP界面类型(上)...
  12. Google 浏览器(2011)书签同步
  13. 快讯丨业界首本云网络图书发布
  14. Wifidog 认证
  15. javaweb关于404、500等错误页面的处理
  16. SQL Server 2000升级sp4补丁的时候出现“以前进行的程序安装创建了挂起的文件操作”的错误!...
  17. 衡量公司盈利能力的重要指标-净资产收益率
  18. 威金蠕虫(网吧杀手)肆虐互联网 九千用户十余企业遭攻击
  19. 看了下华为工资,我不加班了
  20. 计算机未来设计建筑,未来设计的趋势解析,参数化设计及创意设计案例欣赏

热门文章

  1. JS导出 excel
  2. 提高BSEG处理效率
  3. 寻找冬日里的流量美食,发现了李子柒走红的秘密
  4. “200亿先生”沈腾加持,BOSS直聘能让中国人找到好老板吗?
  5. 波司登在“寒潮”下再创新高,羽绒服行业真的靠天吃饭?
  6. 互联网业务利润增长3倍,TCL电子走出第二增长曲线
  7. java 字符串驻留_java String 以及字符串直接量 与 字符串驻留池 ...
  8. mysql数据库怎么安装建表_mysql数据库安装及建表注意事项
  9. 如何编写无法维护的代码_如何写出让同事无法维护的代码?
  10. python apply_async函数_Python-未调用apply_async回调函数