macOS下RabbitMq以及PHP amqp扩展安装记录

记录一下安装配置的过程,这里我都是直接用brew来安装,如果没有安装先安装:

/usr/bin/ruby -e "$(curl -fsSL https://raw.github.com/gist/323731)"

1.首先就是安装rabbitmq了,简单,因为rabbitmq是依赖erlang,所以安装中会下载并且安装erlang,下载编译时间可能会有点长,稍安勿躁:

1
2
brew update  
brew install rabbitmq

2.安装rabbitmq-c,C与RabbitMQ通信需要依赖rabbitmq-c库(librabbitmq),具体请看https://github.com/alanxz/rabbitmq-c

1
2
3
4
git clone git://github.com/alanxz/rabbitmq-c.git  
mkdir build && cd build
cmake -DCMAKE_INSTALL_PREFIX=/usr/local ..
cmake --build . --target install

3.接下来就是安装php amqp的扩展了:
你可以源码编译安装

1
2
3
4
5
6
wget http://pecl.php.net/get/amqp-1.0.0.tgz  
tar zxvf amqp-1.0.0.tgz
cd amqp-1.0.0
/usr/local/php/bin/phpize
./configure –with-php-config=/usr/local/php/bin/php-config –with-amqp
make && make install

当然也可以直接用PECL来装, 如果还没有安装pear的话:

1
2
wget http://pear.php.net/go-pear.phar  
php -d detect_unicode=0 go-pear.phar

然后直接用pecl来安装扩展
~/pear/bin/pecl install amqp

最后将extension=amqp.so加入php.ini,重启apache,再查看下:

php -i | grep amqp

已经装好了!