#!/bin/bash
#root检测
if [ `whoami` != "root" ]; then
echo "error! use root or sudo to run it."
exit 1
fi
cd /tmp
wget http://www.rabbitmq.com/rabbitmq-signing-key-public.asc
apt-key add rabbitmq-signing-key-public.asc
echo "deb http://www.rabbitmq.com/debian/ testing main" > /etc/apt/sources.list.d/rabbitmq.list
apt-get update
apt-get install -y rabbitmq-server
rm /tmp/rabbitmq-signing-key-public.asc
#安装 rabbitmq client端
apt-get install -y librabbitmq-dev git bzr
if [ $? != "0" ]; then
echo "error! rabbitmq is not installed correctly."
exit 2;
fi
cd /tmp
git clone git://github.com/alanxz/rabbitmq-c.git
cd rabbitmq-c
git submodule init
git submodule update
autoreconf -i && ./configure && make && make install
rm -rf /tmp/rabbitmq-c
#安装 amqp 扩展
cd /tmp
wget http://pecl.php.net/get/amqp-1.2.0.tgz
if [ $? != "0" ]; then
echo "error! amqp download error."
exit 3;
fi
tar zxvf amqp-1.2.0.tgz
cd amqp-1.2.0
phpize && ./configure && make && make install
if [ $? != "0" ]; then
echo "error! amqp make error."
exit 4;
fi
rm -rf /tmp/amqp-1.2.0
rm /tmp/amqp-1.2.0.tgz
echo "extension=amqp.so" > /etc/php5/conf.d/amqp.ini
echo "done!"
exit 0
ps:安装amqp扩展时除了源码安装也可以用pecl来安装
例如安装amqp 1.2.0 版本的:pecl install amqp-1.2.0 就行了