首先介绍下AMQP:php
AMQP——高级消息队列协议,目前比较有名气的实现大概就是大名鼎鼎的RabbitMQ了。git
RabbitMQ是一个在AMQP基础上完成的,可复用的企业消息系统。他遵循Mozilla Public License开源协议。github
PHP 下安装拓展:php-fpm
首先去pecl AMQP 下载相关拓展 https://pecl.php.net/package/amqp spa
编译安装以前须要先安装另一个扩展rabbitmq-c 拓展: https://github.com/alanxz/rabbitmq-c/releases/download/v0.8.0/rabbitmq-c-0.8.0.tar.gz .net
wget https://github.com/alanxz/rabbitmq-c/releases/download/v0.8.0/rabbitmq-c-0.8.0.tar.gz (注意: 可能须要FQ) tar zxf rabbitmq-c-0.8.0.tar.gz cd rabbitmq-c-0.8.0.tar.gz ./configure --prefix=/usr/local/rabbitmq-c-0.8.0 make && make install
安装 AMQPcode
wget http://pecl.php.net/get/amqp-1.9.0.tgz tar zxf amqp-1.9.0.tgz cd amqp-1.9.0.tgz /usr/local/php/bin/phpize ./configure --with-php-config=/usr/local/php/bin/php-config --with-amqp --with-librabbitmq-dir=/usr/local/rabbitmq-c-0.8.0
make && make install
不安装拓展会提示如下错误:blog
configure: error: Please reinstall the librabbitmq distribution itself or (re)install librabbitmq development package if it available in your system
而后修改php.ini 把 ampq.so 添加到拓展中,重启php-fpm 即可rabbitmq