安装 php-rabbit: RabbitMQ 的 PHP 扩展

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

完工!!

— EOF —

《安装 php-rabbit: RabbitMQ 的 PHP 扩展》有66个想法

  1. I simply want to mention I’m new to weblog and definitely liked this web-site. More than likely I’m planning to bookmark your website . You absolutely have impressive writings. With thanks for revealing your blog.

  2. I just want to say I’m very new to blogging and site-building and certainly liked this web page. Very likely I’m going to bookmark your blog . You really have incredible articles and reviews. Appreciate it for revealing your website.

  3. I simply want to say I’m beginner to blogging and actually liked your web site. More than likely I’m want to bookmark your site . You definitely have fantastic stories. Bless you for revealing your blog site.

  4. I just want to say I am very new to weblog and absolutely savored you’re web blog. Very likely I’m going to bookmark your website . You definitely have exceptional articles and reviews. Regards for sharing with us your web site.

  5. you are in point of fact a good webmaster. The web site loading speed is amazing. It sort of feels that you’re doing any unique trick. Also, The contents are masterpiece. you’ve performed a fantastic activity in this topic!

  6. I got what you mean , appreciate it for posting .Woh I am glad to find this website through google. “Since the Exodus, freedom has always spoken with a Hebrew accent.” by Heinrich Heine.

  7. Thank you for every other informative web site. The place else may I get that kind of info written in such an ideal manner? I’ve a undertaking that I am just now running on, and I’ve been on the glance out for such info.

  8. Enjoyed looking through this, very good stuff, regards . “Golf isn’t a game, it’s a choice that one makes with one’s life.” by Charles Rosin.

  9. I like the helpful info you provide in your articles. I’ll bookmark your weblog and check again here regularly. I’m quite sure I’ll learn a lot of new stuff right here! Best of luck for the next!

  10. I genuinely enjoy looking through on this web site , it holds great posts . “The secret of eternal youth is arrested development.” by Alice Roosevelt Longworth.

  11. Following study a handful of the content material in your internet website now, and that i genuinely such as your method of blogging. I bookmarked it to my bookmark internet site list and are checking back soon. Pls appear into my site as well and tell me what you believe.

  12. Hey! Do you know if they make any plugins to assist with SEO? I’m trying to get my weblog to rank for some targeted keywords but I’m not seeing very excellent results. If you know of any please share. Thanks!

  13. Hey, you used to write fantastic, but the last several posts have been kinda boring¡K I miss your tremendous writings. Past several posts are just a little bit out of track! come on!

  14. The next time I learn a weblog, I hope that it doesnt disappoint me as considerably as this one. I mean, I do know it was my choice to read, nevertheless I truly thought youd have something attention-grabbing to say. All I hear is a bunch of whining about something which you could fix for those that werent too busy in search of attention.

  15. I just want to mention I am new to blogging and certainly enjoyed you’re web-site. Probably I’m likely to bookmark your blog . You really come with superb articles. Many thanks for sharing your web-site.

  16. Thanks for one’s marvelous posting! I seriously enjoyed reading it, you may be a great author.I will be sure to bookmark your blog and will come back in the future. I want to encourage that you continue your great writing, have a nice morning!

  17. you are actually a excellent webmaster. The web site loading pace is incredible. It kind of feels that you’re doing any unique trick. Also, The contents are masterwork. you’ve performed a excellent process in this matter!

  18. I would like to use the opportunity of saying thanks to you for your specialist direction I’ve constantly enjoyed checking out your internet site. We are searching forward towards the particular commencement of my college research and the entire preparing would never have been complete without visiting your website. If I may be of any assistance to others, I’d personally be pleased to help as a result of what I’ve learned from here.

  19. Excellent entry . Quite generally, the blog is a very good level . Greetings to the author. In your free time, please write more . It reads very nice and interesting reading . We would like to thank you for the article. Regards. Traditional “Księgowa” !

    1.  ( 2012.02.23 10:40 ) : Howdy! Quick question th82;#at17&s totally off topic. Do you know how to make your site mobile friendly? My site looks weird when browsing from my iphone 4. I’m trying to find a theme or plugin that might be able to correct this issue. If you have any suggestions, please share. Thanks!

  20. Hello blogger. I like your weblog about Tales from abroad » Weblog Archive » Rafting. I was wondering, i am planning to make a weblog for myself. I want to use wordpress like you. Exactly where did you get your template? Should you post your answer here below, i will read this inside the next couple of day’s. Thanks bbw webcamsex

  21. Very interesting subject , regards for putting up. “The season of failure is the best time for sowing the seeds of success.” by Paramahansa Yogananda.

  22. This write-up is dedicated to all those who know what is billiard table; to all people who do not know what is pool table; to all people who want to know what is billiards;

  23. You can nonetheless take into consideration a number of advised organized tours with various limo skilled services. A handful of offer medieval software programs numerous will administer you actually to get automobile for any capital center, or maybe checking out the upstate New York. ???????

  24. natural garcinia cambogia at gnc forskolin extract solana beach calif green coffee cleanse ultra walmart on howell acadia biking tours mangosteen nyc weather hoodia drops bottle breacher metamucil psyllium fiber supplement capsules chitosan lotion for stretch guar gum machinery china lipozene kmart layaway glucomannan lowest price guarantee

  25. You can definitely see your enthusiasm within the work you write. The world hopes for even more passionate writers such as you who are not afraid to mention how they believe. Always go after your heart. “Man is the measure of all things.” by Protagoras.

  26. I have learn several just right stuff here. Definitely price bookmarking for revisiting. I surprise how a lot effort you put to make the sort of excellent informative web site.|

发表评论

电子邮件地址不会被公开。 必填项已用*标注