日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > php >内容正文

php

php 安装rabbitmq拓展_安装 php-rabbit: RabbitMQ 的 PHP 扩展

發布時間:2025/3/19 php 22 豆豆
生活随笔 收集整理的這篇文章主要介紹了 php 安装rabbitmq拓展_安装 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

完工!!

總結

以上是生活随笔為你收集整理的php 安装rabbitmq拓展_安装 php-rabbit: RabbitMQ 的 PHP 扩展的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。