php擴展AMQP,安裝報錯解決


接下來來安裝php擴展AMQP,安裝了它以后,才能用PHP操作rabbitmq。

wget https://pecl.php.net/get/amqp-1.4.0.tgz
tar -zxvf amqp-1.4.0.tgz
cd amqp-1.4.0
/lnmp/php/bin/phpize
./configure --with-php-config=/lnmp/php/bin/php-config

安裝到這,就報了錯:
checking for amqp files in default path… not found
configure: error: Please reinstall the librabbit-mq distribution

在網上搜了搜,找到了解決方法(http://www.cnphp6.com/archives/68356):
需要安裝rabbitmq-c,rabbitmq-c是一個用於C語言的,與AMQP server進行交互的client庫。
下載地址:https://github.com/alanxz/rabbitmq-c

unzip rabbitmq-c-master.zip
cd rabbitmq-c-master
autoreconf -i
./configure --prefix=/lnmp/rabbitmq-c
make
make install

額,接着安裝PHP擴展AMQP

./configure --with-php-config=/lnmp/php/bin/php-config --with-amqp --with-librabbitmq-dir=/lnmp/rabbitmq-c
make && make install

草,又報錯啦:
/software/amqp-1.4.0/amqp_exchange.c:515: error: incompatible type for argument 7 of ‘amqp_exchange_declare’
/lnmp/rabbitmq-c//include/amqp_framing.h:798: note: expected ‘amqp_boolean_t’ but argument is of type ‘amqp_table_t’
/software/amqp-1.4.0/amqp_exchange.c:515: error: too few arguments to function ‘amqp_exchange_declare’
make: *** [amqp_exchange.lo] Error 1
在https://github.com/pdezwart/php-amqp/issues/127找到了方法:
應該是安裝的rabbitmq-c的版本太高了(安裝的是 v0.6.0),下載了v0.5.2版本(https://github.com/alanxz/rabbitmq-c/releases/download/v0.5.2/rabbitmq-c-0.5.2.tar.gz),重新安裝rabbitmq-c,重新安裝php擴展AMQP,終於可以啦。真是一波三折啊。

在php配置文件里將擴展加上,重啟一下,看phpinfo,顯示如下圖即安裝成功。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM