首先介紹下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