用于ubuntu的默认源里面没有php5-amqp这个包,所以要用上amqp得考手动编译。
首先安装必须的php编译工具
sudo apt-get install php5-dev
sudo apt-get install librabbitmq-dev
git clone git://github.com/alanxz/rabbitmq-c.git cd rabbitmq-c git submodule init git submodule update
autoreconf -i && ./configure && make && sudo make install
当前最新版本为1.0.10
wget http://pecl.php.net/get/amqp-1.0.10.tgz tar zxf amqp-1.0.10.tgz cd amqp-1.0.10/ phpize && ./configure --with-amqp && make && sudo make install如果报错
/root/amqp-1.0.9/amqp_queue.c: In function ‘read_message_from_channel’: /root/amqp-1.0.9/amqp_queue.c:341:11: error: ‘AMQP_FIELD_KIND_U64’ undeclared (first use in this function) /root/amqp-1.0.9/amqp_queue.c:341:11: note: each undeclared identifier is reported only once for each function it appears in /root/amqp-1.0.9/amqp_queue.c: In function ‘zim_amqp_queue_class_nack’: /root/amqp-1.0.9/amqp_queue.c:1093:2: error: unknown type name ‘amqp_basic_nack_t’ /root/amqp-1.0.9/amqp_queue.c:1113:3: error: request for member ‘delivery_tag’ in something not a structure or union /root/amqp-1.0.9/amqp_queue.c:1114:3: error: request for member ‘multiple’ in something not a structure or union /root/amqp-1.0.9/amqp_queue.c:1115:3: error: request for member ‘requeue’ in something not a structure or union /root/amqp-1.0.9/amqp_queue.c:1120:3: error: ‘AMQP_BASIC_NACK_METHOD’ undeclared (first use in this function) make: *** [amqp_queue.lo] Error 1
最后一步创建配置文件
sudo echo "extension = amqp.so" > /etc/php5/conf.d/amqp.ini