安装 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/

 

 

安装步骤:

下载 RabbitMQ-C 客户端库 librabbitmq:
http://hg.rabbitmq.com/rabbitmq-c/
下载 RabbitMQ 协议代码生成工具:
http://hg.rabbitmq.com/rabbitmq-codegen/

具体命令

yum -y install libtool

mkdir /usr/local/src/tmp

cd /usr/local/src/tmp

wget http://hg.rabbitmq.com/rabbitmq-c/archive/default.tar.gz
wget http://hg.rabbitmq.com/rabbitmq-codegen/archive/default.tar.gz

tar xzf default.tar.gz tar xzf default.tar.gz.1

mv rabbitmq-codegen-default/ rabbitmq-c-default/codegen

cd rabbitmq-c-default/

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

 

--------------------------------------------------------------------------------------

另外一种安装

yum -y install libtool

mkdir /usr/local/src/tmp

cd /usr/local/src/tmp

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/ /codegen
cd rabbitmq-c-ce1eaceaee94/
autoreconf -i && ./configure && make && make install

如果在./configure 时有下面提示

checking location of AMQP codegen directory... configure: error: could not find AMQP spec file at "'/codegen/amqp-0.8.json'"

切记rabbitmq-codegen要移到根目录下

 

如果提示:

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

--------------------------------------------------------------------------------------------------------

实际下载http://php-rabbit.googlecode.com/files/php-rabbit.r91.tar.gz,提示403没有权限,不知为啥

 

 

 

 

 

-------------------------------------------------------------------------------------------------------

下载并安装 php-rabbit:

# wget http://pecl.php.net/get/amqp-0.2.2.tgz
# tar zxf amqp-0.2.2.tgz
# cd amqp-0.2.2
# /usr/local/php/bin/phpize
# ./configure –with-php-config=/usr/bin/php-config –with-amqp
# make && make install

注:上面是pecl上的包可以用,但如果使用google code上的(http://code.google.com/p/php-amqp/downloads/list)则报如下错误

/root/tool/amqp-0.0.7/amqp.c: In function ‘zif_amqp_login’:
/root/tool/amqp-0.0.7/amqp.c:372: error: incompatible type for argument 6 of ‘amqp_login’
/root/tool/amqp-0.0.7/amqp.c: In function ‘zif_amqp_exchange_declare’:
/root/tool/amqp-0.0.7/amqp.c:656: warning: passing argument 4 of ‘amqp_simple_rpc’ makes pointer from integer without a cast
/root/tool/amqp-0.0.7/amqp.c: In function ‘zif_amqp_queue_declare’:
/root/tool/amqp-0.0.7/amqp.c:722: warning: passing argument 4 of ‘amqp_simple_rpc’ makes pointer from integer without a cast
/root/tool/amqp-0.0.7/amqp.c: In function ‘zif_amqp_queue_bind’:
/root/tool/amqp-0.0.7/amqp.c:784: warning: passing argument 4 of ‘amqp_simple_rpc’ makes pointer from integer without a cast
/root/tool/amqp-0.0.7/amqp.c: In function ‘zif_amqp_queue_unbind’:
/root/tool/amqp-0.0.7/amqp.c:847: warning: passing argument 4 of ‘amqp_simple_rpc’ makes pointer from integer without a cast
/root/tool/amqp-0.0.7/amqp.c: In function ‘_php_amqp_error’:
/root/tool/amqp-0.0.7/amqp.c:870: error: ‘amqp_rpc_reply_t’ has no member named ‘library_errno’
/root/tool/amqp-0.0.7/amqp.c:870: error: ‘amqp_rpc_reply_t’ has no member named ‘library_errno’
make: *** [amqp.lo] Error 1

修改 php.ini,在尾部加上:
extension = amqp.so

查看扩展是否安装成功:
# php -m | grep amqp
rabbit

 

 

 

 

 

你可能感兴趣的:(linux系统管理)