CentOS 6編譯安裝RabbitMQ

編譯安裝Python

下載python源文件php

[root@localhost src]# tar -xzvf python-2.7.11.tar.gz
[root@localhost src]# cd python-2.7.11
[root@localhost python-2.7.11]# ./configure --prefix=/usr/local/python
[root@localhost python-2.7.11]# make && make install

# 創建軟鏈接,使系統默認的python指向新的python
[root@localhost python-2.7.11]# mv /usr/bin/python /usr/bin/python2.6.6.old 
[root@localhost python-2.7.11]# ln -s /usr/local/python/bin/python /usr/bin/python	

# 查看python的新版本
[root@localhost python-2.7.11]# python -V

# 安裝完新的python以後,使用yum命令會出現問題(yum默認版本爲2.6.6),須要修改yum的默認python配置版本
[root@localhost ~]# vim /usr/bin/yum
將文件頭部的#!/usr/bin/python改成 
#!/usr/bin/python2.6

編譯安裝erlang

RabbitMQ是基於erlang開發的java

下載源文件:本次安裝的版本爲R15B03-1python

# 安裝erlang的依賴軟件模塊
[root@localhost ~]# yum -y install make gcc gcc-c++ kernel-devel m4 ncurses-devel openssl-devel
# 安裝ncurses模塊
[root@localhost ~]# yum -y install ncurses-devel 
[root@localhost ~]# yum install ncurses-devel

[root@localhost src]# tar -xzvf otp_src_R15B03-1.tar.gz
[root@localhost src]# mv otp_src_R15B03-1 erlang_R15B # 重命名解壓後的文件

[root@localhost src]# cd erlang_R15B
[root@localhost erlang_R15B]# ./configure --prefix=/usr/local/erlang --with-ssl --enable-threads --enable-smp-support --enable-kernel-poll --enable-hipe --without-javac
[root@localhost erlang_R15B]# make && make install

[root@localhost erlang_R15B]# vim /etc/profile 
添加一下兩行:
ERL_HOME=/usr/local/erlang
export PATH=$PATH:$ERL_HOME/bin
[root@localhost erlang_R15B]# source /etc/profile

# 測試是否安裝成功
[root@localhost erlang_R15B]# erl

編譯安裝rabbitmq-server

下載rabbitmq的源文件c++

[root@localhost ~]# tar -zxvf rabbitmq-server-3.1.1.tar.gz 
[root@localhost ~]# cd rabbitmq-server-3.1.1
# 安裝依賴包xmlto
[root@localhost rabbitmq-server-3.1.1]# yum install xmlto
[root@localhost rabbitmq-server-3.1.1]# make 
[root@localhost rabbitmq-server-3.1.1]# make install TARGET_DIR=/opt/rabbitmq SBIN_DIR=/opt/rabbitmq/sbin MAN_DIR=/opt/rabbitmq/man
## 命令目錄:/opt/rabbitmq/sbin  
## 使用手冊目錄:/opt/rabbitmq/man

# 安裝web插件管理界面
[root@localhost ~]# cd /opt/rabbitmq/sbin
[root@localhost sbin]# ./rabbitmq-plugins enable rabbitmq_management
[root@localhost sbin]# mkdir /etc/rabbitmq/

# 啓動rabbitmq
[root@localhost sbin]# ./rabbitmq-server start  # 默認監聽端口5672,web管理界面端口爲15672
[root@localhost sbin]# vim /etc/sysconfig/iptables
添加如下:
-A INPUT -m state --state NEW -m tcp -p tcp --dport 15672 -j ACCEPT
[root@localhost sbin]# /etc/rc.d/init.d/iptables restart

## 使用登陸的名戶名和密碼默認都爲guest

# 開啓關閉命令:
[root@localhost ~]# /opt/rabbitmq/sbin/rabbitmq-server -detached     # 啓動rabbitMQ
[root@localhost ~]# /opt/rabbitmq/sbin/rabbitmqctl status 			 # 查看狀態
[root@localhost ~]# /opt/rabbitmq/sbin/rabbitmqctl stop				 # 關閉rabbitMQ

# 啓動管理插件:
[root@localhost ~]# /opt/rabbitmq/sbin/rabbitmq-plugins enable rabbitmq_management   # 啓動插件
[root@localhost ~]# /opt/rabbitmq/sbin/rabbitmq-plugins disable rabbitmq_management  # 禁用插件

PHP編譯安裝rabbitmq擴展

訪問https://github.com/alanxz/rabbitmq-c下載最新版的源文件
訪問http://pecl.php.net/package/amqp下載最新版的源文件git

[root@localhost ~]# cd /usr/local/src 
[root@localhost src]# tar zxvf rabbitmq-c-x.x.x.tar.gz
[root@localhost src]# tar zxvf amqp-x.x.x.tgz
	
[root@localhost src]# cd rabbitmq-c-x.x.x
[root@localhost rabbitmq-c-x.x.x]# ./configure --prefix=/usr/local/rabbitmq
[root@localhost rabbitmq-c-x.x.x]# make && make install

[root@localhost ~]# cd amqp-x.x.x
[root@localhost amqp-x.x.x]# phpize
[root@localhost amqp-x.x.x]# ./configure --with-php-config=/usr/local/php/bin/php-config --with-amqp --with-librabbitmq-dir=/usr/local/rabbitmq
# php-config 是你當前的php安裝路徑決定,librabbitmq-dir則是根據你當前的rabbitmq-c的安裝目錄而決定的。
[root@localhost amqp-x.x.x]# make && make install

[root@localhost amqp-x.x.x]# vim /usr/local/php/etc/php.ini
添加以下:
extension=amqp.so
[root@localhost amqp-x.x.x]# service httpd restart
相關文章
相關標籤/搜索