Linux环境下安装rabbitmq


###2018.03.15 rabbitmq-server-3.6.12的安装部署
#  检查是否已经安装旧版本的软件
[root@localhost src]# rpm -qa|grep erlang
[root@localhost src]# rpm -qa|grep rabbitmq
# 如果之前yum安装过rabbitmq可能会有旧版本的软件,需要卸载掉再安装
# yum remove erlang-R14B erlang-erts -y
# 配置rabbitmq所需要的yum源(epel源)
[root@localhost src]# rpm -Uvh http://download.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-8.noarch.rpm
Retrieving http://download.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-8.noarch.rpm
curl: (22) The requested URL returned error: 404 Not Found
error: skipping http://download.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-8.noarch.rpm - transfer failed
[root@localhost src]# rpm -Uvh http://download.Fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
Retrieving http://download.Fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
warning: /var/tmp/rpm-tmp.nKc47n: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY
Preparing...                          ################################# [100%]
        package epel-release-7-11.noarch (which is newer than epel-release-6-8.noarch) is already installed
# 安装指定版本的rabbitmq
[root@localhost src]# wget http://www.rabbitmq.com/releases/erlang/erlang-19.0.4-1.el6.x86_64.rpm
--2018-03-15 03:26:57--  http://www.rabbitmq.com/releases/erlang/erlang-19.0.4-1.el6.x86_64.rpm
Resolving www.rabbitmq.com (www.rabbitmq.com)... 104.20.62.197, 104.20.63.197, 2400:cb00:2048:1::6814:3fc5, ...
Connecting to www.rabbitmq.com (www.rabbitmq.com)|104.20.62.197|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 18585932 (18M) [application/x-redhat-package-manager]
Saving to: ‘erlang-19.0.4-1.el6.x86_64.rpm’


100%[==========================================================================================================================>] 18,585,932   760KB/s   in 15s    


2018-03-15 03:27:13 (1.17 MB/s) - ‘erlang-19.0.4-1.el6.x86_64.rpm’ saved [18585932/18585932]


[root@localhost src]# wget http://www.rabbitmq.com/releases/rabbitmq-server/v3.6.12/rabbitmq-server-3.6.12-1.el6.noarch.rpm
--2018-03-15 03:27:41--  http://www.rabbitmq.com/releases/rabbitmq-server/v3.6.12/rabbitmq-server-3.6.12-1.el6.noarch.rpm
Resolving www.rabbitmq.com (www.rabbitmq.com)... 104.20.62.197, 104.20.63.197, 2400:cb00:2048:1::6814:3fc5, ...
Connecting to www.rabbitmq.com (www.rabbitmq.com)|104.20.62.197|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 4964260 (4.7M) [application/x-redhat-package-manager]
Saving to: ‘rabbitmq-server-3.6.12-1.el6.noarch.rpm’


100%[==========================================================================================================================>] 4,964,260    674KB/s   in 9.4s   


2018-03-15 03:27:51 (517 KB/s) - ‘rabbitmq-server-3.6.12-1.el6.noarch.rpm’ saved [4964260/4964260]


[root@localhost src]# yum install erlang-19.0.4-1.el6.x86_64.rpm -y
Loaded plugins: fastestmirror
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
Examining erlang-19.0.4-1.el6.x86_64.rpm: erlang-19.0.4-1.el6.x86_64
Marking erlang-19.0.4-1.el6.x86_64.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package erlang.x86_64 0:19.0.4-1.el6 will be installed
--> Finished Dependency Resolution


Dependencies Resolved


====================================================================================================================================================================
 Package                         Arch                            Version                                 Repository                                            Size
====================================================================================================================================================================
Installing:
 erlang                          x86_64                          19.0.4-1.el6                            /erlang-19.0.4-1.el6.x86_64                           32 M


Transaction Summary
====================================================================================================================================================================
Install  1 Package


Total size: 32 M
Installed size: 32 M
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : erlang-19.0.4-1.el6.x86_64                                                                                                                       1/1 
  Verifying  : erlang-19.0.4-1.el6.x86_64                                                                                                                       1/1 


Installed:
  erlang.x86_64 0:19.0.4-1.el6                                                                                                                                      


Complete!
[root@localhost src]# yum install rabbitmq-server-3.6.12-1.el6.noarch.rpm -y
# 启动rabbitmq
[root@localhost src]# service rabbitmq-server start
ps -ef|grep rabbitmq
#配置开机自启动
chkconfig rabbitmq-server on
chkconfig --list rabbitmq-server
# 设置rabbitmq启用的功能
rabbitmq-plugins enable rabbitmq_management
service rabbitmq-server restart
# 默认的用户密码为guest,可以创建新的rabbitmq用户并授权
rabbitmqctl add_user admin 123456
rabbitmqctl set_user_tags admin administrator
rabbitmqctl set_permissions -p "/" admin ".*" ".*" ".*"


可以访问:http://IP:15672




##安装amqp扩展

cd /usr/local/src/
wget -c https://pecl.php.net/get/amqp-1.9.3.tgz
tar zxvf amqp-1.9.3.tgz
wget -c https://github.com/alanxz/rabbitmq-c/releases/download/v0.8.0/rabbitmq-c-0.8.0.tar.gz
tar zxvf rabbitmq-c-0.8.0.tar.gz


[root@localhost src]# cd rabbitmq-c-0.8.0
[root@localhost rabbitmq-c-0.8.0]# ./configure --prefix=/usr/local/
bin/      etc/      games/    include/  lib/      lib64/    libexec/  memcache/ mongodb/  mysql/    nginx/    php/      sbin/     share/    src/      
[root@localhost rabbitmq-c-0.8.0]# ./configure --prefix=/usr/local/rabbitmq-c-0.8.0
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether make supports nested variables... (cached) yes
checking for style of include used by make... GNU
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether gcc understands -c and -o together... yes
checking dependency style of gcc... gcc3
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking minix/config.h usability... no
checking minix/config.h presence... no
checking for minix/config.h... no
checking whether it is safe to define __EXTENSIONS__... yes
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking how to print strings... printf
checking for a sed that does not truncate output... /usr/bin/sed
checking for fgrep... /usr/bin/grep -F
checking for ld used by gcc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 1572864
checking whether the shell understands some XSI constructs... yes
checking whether the shell understands "+="... yes
checking how to convert x86_64-unknown-linux-gnu file names to x86_64-unknown-linux-gnu format... func_convert_file_noop
checking how to convert x86_64-unknown-linux-gnu file names to toolchain format... func_convert_file_noop
checking for /usr/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for ar... ar
checking for archiver @FILE support... @
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/bin/nm -B output from gcc object... ok
checking for sysroot... no
checking for mt... no
checking if : is a manifest tool... no
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... no
checking for gcc option to produce PIC... -fPIC -DPIC
checking if gcc PIC flag -fPIC -DPIC works... yes
checking if gcc static flag -static works... no
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... no
configure: WARNING: Attempt c89 workaround for old versions of autoconf
checking for gcc... (cached) gcc
checking whether we are using the GNU C compiler... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for gcc option to accept ISO C89... (cached) none needed
checking whether gcc understands -c and -o together... (cached) yes
checking dependency style of gcc... (cached) gcc3
checking if compiler accepts '-std=gnu90'... yes
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.17... yes
checking for inline... inline
checking if compiler accepts '-Wall'... yes
checking if compiler accepts '-Wextra'... yes
checking if compiler accepts '-Wstrict-prototypes'... yes
checking if compiler accepts '-Wno-unused-function'... yes
checking if compiler accepts '-fno-common'... yes
checking if compiler accepts '-fvisibility=hidden'... yes
checking if linker accepts '-no-undefined'... no
checking for library containing getaddrinfo... none required
checking for library containing socket... none required
checking for library containing clock_gettime... none required
checking for library containing posix_spawnp... none required
checking if htonll is defined... no
checking for poll(2)... yes
checking for SSL... yes
checking for popt.h... no
checking for poptGetContext in -lpopt... no
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating librabbitmq.pc
config.status: creating Makefile
config.status: creating config.h
config.status: executing depfiles commands
config.status: executing libtool commands


rabbitmq-c build options:
    Host: x86_64-unknown-linux-gnu
    Version: 0.8.0
    SSL/TLS: openssl
    Tools: no
    Documentation: no
    Examples: yes


[root@localhost rabbitmq-c-0.8.0]# make && make install
make  all-am
make[1]: Entering directory `/usr/local/src/rabbitmq-c-0.8.0'
  CC       librabbitmq/librabbitmq_librabbitmq_la-amqp_api.lo
  CC       librabbitmq/librabbitmq_librabbitmq_la-amqp_connection.lo
  CC       librabbitmq/librabbitmq_librabbitmq_la-amqp_consumer.lo
  CC       librabbitmq/librabbitmq_librabbitmq_la-amqp_framing.lo
  CC       librabbitmq/librabbitmq_librabbitmq_la-amqp_mem.lo
  CC       librabbitmq/librabbitmq_librabbitmq_la-amqp_socket.lo
  CC       librabbitmq/librabbitmq_librabbitmq_la-amqp_table.lo
  CC       librabbitmq/librabbitmq_librabbitmq_la-amqp_tcp_socket.lo
  CC       librabbitmq/librabbitmq_librabbitmq_la-amqp_time.lo
  CC       librabbitmq/librabbitmq_librabbitmq_la-amqp_url.lo
  CC       librabbitmq/librabbitmq_librabbitmq_la-amqp_hostcheck.lo
  CC       librabbitmq/librabbitmq_librabbitmq_la-amqp_openssl.lo
  CC       librabbitmq/librabbitmq_librabbitmq_la-amqp_openssl_hostname_validation.lo
  CCLD     librabbitmq/librabbitmq.la
  CC       examples/examples_libutils_la-utils.lo
  CC       examples/unix/examples_libutils_la-platform_utils.lo
  CCLD     examples/libutils.la
  CC       examples/amqp_bind.o
  CCLD     examples/amqp_bind
  CC       examples/amqp_consumer.o
  CCLD     examples/amqp_consumer
  CC       examples/amqp_connect_timeout.o
  CCLD     examples/amqp_connect_timeout
  CC       examples/amqp_exchange_declare.o
  CCLD     examples/amqp_exchange_declare
  CC       examples/amqp_listen.o
  CCLD     examples/amqp_listen
  CC       examples/amqp_listenq.o
  CCLD     examples/amqp_listenq
  CC       examples/amqp_producer.o
  CCLD     examples/amqp_producer
  CC       examples/amqp_rpc_sendstring_client.o
  CCLD     examples/amqp_rpc_sendstring_client
  CC       examples/amqp_sendstring.o
  CCLD     examples/amqp_sendstring
  CC       examples/amqp_unbind.o
  CCLD     examples/amqp_unbind
  CC       examples/amqps_bind.o
  CCLD     examples/amqps_bind
  CC       examples/amqps_connect_timeout.o
  CCLD     examples/amqps_connect_timeout
  CC       examples/amqps_consumer.o
  CCLD     examples/amqps_consumer
  CC       examples/amqps_exchange_declare.o
  CCLD     examples/amqps_exchange_declare
  CC       examples/amqps_listen.o
  CCLD     examples/amqps_listen
  CC       examples/amqps_listenq.o
  CCLD     examples/amqps_listenq
  CC       examples/amqps_producer.o
  CCLD     examples/amqps_producer
  CC       examples/amqps_sendstring.o
  CCLD     examples/amqps_sendstring
  CC       examples/amqps_unbind.o
  CCLD     examples/amqps_unbind
make[1]: Leaving directory `/usr/local/src/rabbitmq-c-0.8.0'
make[1]: Entering directory `/usr/local/src/rabbitmq-c-0.8.0'
 /usr/bin/mkdir -p '/usr/local/rabbitmq-c-0.8.0/lib'
 /bin/sh ./libtool   --mode=install /usr/bin/install -c   librabbitmq/librabbitmq.la '/usr/local/rabbitmq-c-0.8.0/lib'
libtool: install: /usr/bin/install -c librabbitmq/.libs/librabbitmq.so.4.2.0 /usr/local/rabbitmq-c-0.8.0/lib/librabbitmq.so.4.2.0
libtool: install: (cd /usr/local/rabbitmq-c-0.8.0/lib && { ln -s -f librabbitmq.so.4.2.0 librabbitmq.so.4 || { rm -f librabbitmq.so.4 && ln -s librabbitmq.so.4.2.0 librabbitmq.so.4; }; })
libtool: install: (cd /usr/local/rabbitmq-c-0.8.0/lib && { ln -s -f librabbitmq.so.4.2.0 librabbitmq.so || { rm -f librabbitmq.so && ln -s librabbitmq.so.4.2.0 librabbitmq.so; }; })
libtool: install: /usr/bin/install -c librabbitmq/.libs/librabbitmq.lai /usr/local/rabbitmq-c-0.8.0/lib/librabbitmq.la
libtool: finish: PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/usr/local/php/bin:/usr/local/mysql/bin:/root/bin:/sbin" ldconfig -n /usr/local/rabbitmq-c-0.8.0/lib
----------------------------------------------------------------------
Libraries have been installed in:
   /usr/local/rabbitmq-c-0.8.0/lib


If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the `LD_RUN_PATH' environment variable
     during linking
   - use the `-Wl,-rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to `/etc/ld.so.conf'


See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
 /usr/bin/mkdir -p '/usr/local/rabbitmq-c-0.8.0/include'
 /usr/bin/install -c -m 644 librabbitmq/amqp.h librabbitmq/amqp_framing.h librabbitmq/amqp_tcp_socket.h librabbitmq/amqp_ssl_socket.h '/usr/local/rabbitmq-c-0.8.0/include'
 /usr/bin/mkdir -p '/usr/local/rabbitmq-c-0.8.0/lib/pkgconfig'
 /usr/bin/install -c -m 644 librabbitmq.pc '/usr/local/rabbitmq-c-0.8.0/lib/pkgconfig'
make[1]: Leaving directory `/usr/local/src/rabbitmq-c-0.8.0'


[root@localhost src]# cd amqp-1.9.3 
[root@localhost amqp-1.9.3]# ll
total 404
-rw-r--r--. 1 root root 26214 Oct 19 09:51 amqp_basic_properties.c
-rw-r--r--. 1 root root  2109 Oct 19 09:51 amqp_basic_properties.h
-rw-r--r--. 1 root root 13625 Oct 19 09:51 amqp.c
-rw-r--r--. 1 root root 41242 Oct 19 09:51 amqp_channel.c
-rw-r--r--. 1 root root  1821 Oct 19 09:51 amqp_channel.h
-rw-r--r--. 1 root root 51694 Oct 19 09:51 amqp_connection.c
-rw-r--r--. 1 root root  1935 Oct 19 09:51 amqp_connection.h
-rw-r--r--. 1 root root 21874 Oct 19 09:51 amqp_connection_resource.c
-rw-r--r--. 1 root root  3934 Oct 19 09:51 amqp_connection_resource.h
-rw-r--r--. 1 root root  5623 Oct 19 09:51 amqp_decimal.c
-rw-r--r--. 1 root root  1734 Oct 19 09:51 amqp_decimal.h
-rw-r--r--. 1 root root  9821 Oct 19 09:51 amqp_envelope.c
-rw-r--r--. 1 root root  1814 Oct 19 09:51 amqp_envelope.h
-rw-r--r--. 1 root root 30297 Oct 19 09:51 amqp_exchange.c
-rw-r--r--. 1 root root  1719 Oct 19 09:51 amqp_exchange.h
-rw-r--r--. 1 root root  9744 Oct 19 09:51 amqp_methods_handling.c
-rw-r--r--. 1 root root  3367 Oct 19 09:51 amqp_methods_handling.h
-rw-r--r--. 1 root root 43802 Oct 19 09:51 amqp_queue.c
-rw-r--r--. 1 root root  1713 Oct 19 09:51 amqp_queue.h
-rw-r--r--. 1 root root  5077 Oct 19 09:51 amqp_timestamp.c
-rw-r--r--. 1 root root  1738 Oct 19 09:51 amqp_timestamp.h
-rw-r--r--. 1 root root 10866 Oct 19 09:51 amqp_type.c
-rw-r--r--. 1 root root  2548 Oct 19 09:51 amqp_type.h
-rw-r--r--. 1 root root  2859 Oct 19 09:51 benchmark.php
-rw-r--r--. 1 root root  3988 Oct 19 09:51 config.m4
-rw-r--r--. 1 root root   634 Oct 19 09:51 config.w32
-rw-r--r--. 1 root root   771 Oct 19 09:51 CREDITS
-rw-r--r--. 1 root root  3204 Oct 19 09:51 LICENSE
-rw-r--r--. 1 root root  5409 Oct 19 09:51 php5_support.h
-rw-r--r--. 1 root root  5267 Oct 19 09:51 php7_support.h
-rw-r--r--. 1 root root 15166 Oct 19 09:51 php_amqp.h
drwxr-xr-x. 2 root root  4096 Mar 19 04:30 stubs
drwxr-xr-x. 2 root root  8192 Mar 19 04:30 tests
[root@localhost amqp-1.9.3]# /usr/local/php/bin/phpize 
Configuring for:
PHP Api Version:         20131106
Zend Module Api No:      20131226
Zend Extension Api No:   220131226
[root@localhost amqp-1.9.3]# ./configure --with-php-config=/usr/local/php/
bin/     etc/     include/ lib/     php/     sbin/    var/     
[root@localhost amqp-1.9.3]# ./configure --with-php-config=/usr/local/php/bin/php
php         php-cgi     php-config  phpize      
[root@localhost amqp-1.9.3]# ./configure --with-php-config=/usr/local/php/bin/php-c
php-cgi     php-config  
[root@localhost amqp-1.9.3]# ./configure --with-php-config=/usr/local/php/bin/php-config --with-amqp --with-librabbitmq-dir=/usr/local/
bin/              games/            lib/              libexec/          mongodb/          nginx/            rabbitmq-c-0.8.0/ share/            
etc/              include/          lib64/            memcache/         mysql/            php/              sbin/             src/              
[root@localhost amqp-1.9.3]# ./configure --with-php-config=/usr/local/php/bin/php-config --with-amqp --with-librabbitmq-dir=/usr/local/rabbitmq-c-0.8.0/
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for a sed that does not truncate output... /usr/bin/sed
checking for cc... cc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether cc accepts -g... yes
checking for cc option to accept ISO C89... none needed
checking how to run the C preprocessor... cc -E
checking for icc... no
checking for suncc... no
checking whether cc understands -c and -o together... yes
checking for system library directory... lib
checking if compiler supports -R... no
checking if compiler supports -Wl,-rpath,... yes
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking for PHP prefix... /usr/local/php
checking for PHP includes... -I/usr/local/php/include/php -I/usr/local/php/include/php/main -I/usr/local/php/include/php/TSRM -I/usr/local/php/include/php/Zend -I/usr/local/php/include/php/ext -I/usr/local/php/include/php/ext/date/lib
checking for PHP extension directory... /usr/local/php/lib/php/extensions/no-debug-non-zts-20131226
checking for PHP installed headers prefix... /usr/local/php/include/php
checking if debug is enabled... no
checking if zts is enabled... no
checking for re2c... no
configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.
checking for gawk... gawk
checking for amqp support... yes, shared
checking for amqp... yes, shared
yes
checking for pkg-config... /usr/bin/pkg-config
checking for amqp files in default path... found in /usr/local/rabbitmq-c-0.8.0/
checking for librabbitmq version... 0.8.0
checking for ld used by cc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for /usr/bin/ld option to reload object files... -r
checking for BSD-compatible nm... /usr/bin/nm -B
checking whether ln -s works... yes
checking how to recognize dependent libraries... pass_all
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking dlfcn.h usability... yes
checking dlfcn.h presence... yes
checking for dlfcn.h... yes
checking the maximum length of command line arguments... 1572864
checking command to parse /usr/bin/nm -B output from cc object... ok
checking for objdir... .libs
checking for ar... ar
checking for ranlib... ranlib
checking for strip... strip
checking if cc supports -fno-rtti -fno-exceptions... no
checking for cc option to produce PIC... -fPIC
checking if cc PIC flag -fPIC works... yes
checking if cc static flag -static works... no
checking if cc supports -c -o file.o... yes
checking whether the cc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... no


creating libtool
appending configuration tag "CXX" to libtool
configure: creating ./config.status
config.status: creating config.h
[root@localhost amqp-1.9.3]# make && make install
/bin/sh /usr/local/src/amqp-1.9.3/libtool --mode=compile cc  -I. -I/usr/local/src/amqp-1.9.3 -DPHP_ATOM_INC -I/usr/local/src/amqp-1.9.3/include -I/usr/local/src/amqp-1.9.3/main -I/usr/local/src/amqp-1.9.3 -I/usr/local/php/include/php -I/usr/local/php/include/php/main -I/usr/local/php/include/php/TSRM -I/usr/local/php/include/php/Zend -I/usr/local/php/include/php/ext -I/usr/local/php/include/php/ext/date/lib -I/usr/local/rabbitmq-c-0.8.0//include  -DHAVE_CONFIG_H  -g -O2   -c /usr/local/src/amqp-1.9.3/amqp.c -o amqp.lo 
mkdir .libs
 cc -I. -I/usr/local/src/amqp-1.9.3 -DPHP_ATOM_INC -I/usr/local/src/amqp-1.9.3/include -I/usr/local/src/amqp-1.9.3/main -I/usr/local/src/amqp-1.9.3 -I/usr/local/php/include/php -I/usr/local/php/include/php/main -I/usr/local/php/include/php/TSRM -I/usr/local/php/include/php/Zend -I/usr/local/php/include/php/ext -I/usr/local/php/include/php/ext/date/lib -I/usr/local/rabbitmq-c-0.8.0//include -DHAVE_CONFIG_H -g -O2 -c /usr/local/src/amqp-1.9.3/amqp.c  -fPIC -DPIC -o .libs/amqp.o
/bin/sh /usr/local/src/amqp-1.9.3/libtool --mode=compile cc  -I. -I/usr/local/src/amqp-1.9.3 -DPHP_ATOM_INC -I/usr/local/src/amqp-1.9.3/include -I/usr/local/src/amqp-1.9.3/main -I/usr/local/src/amqp-1.9.3 -I/usr/local/php/include/php -I/usr/local/php/include/php/main -I/usr/local/php/include/php/TSRM -I/usr/local/php/include/php/Zend -I/usr/local/php/include/php/ext -I/usr/local/php/include/php/ext/date/lib -I/usr/local/rabbitmq-c-0.8.0//include  -DHAVE_CONFIG_H  -g -O2   -c /usr/local/src/amqp-1.9.3/amqp_type.c -o amqp_type.lo 
 cc -I. -I/usr/local/src/amqp-1.9.3 -DPHP_ATOM_INC -I/usr/local/src/amqp-1.9.3/include -I/usr/local/src/amqp-1.9.3/main -I/usr/local/src/amqp-1.9.3 -I/usr/local/php/include/php -I/usr/local/php/include/php/main -I/usr/local/php/include/php/TSRM -I/usr/local/php/include/php/Zend -I/usr/local/php/include/php/ext -I/usr/local/php/include/php/ext/date/lib -I/usr/local/rabbitmq-c-0.8.0//include -DHAVE_CONFIG_H -g -O2 -c /usr/local/src/amqp-1.9.3/amqp_type.c  -fPIC -DPIC -o .libs/amqp_type.o
/bin/sh /usr/local/src/amqp-1.9.3/libtool --mode=compile cc  -I. -I/usr/local/src/amqp-1.9.3 -DPHP_ATOM_INC -I/usr/local/src/amqp-1.9.3/include -I/usr/local/src/amqp-1.9.3/main -I/usr/local/src/amqp-1.9.3 -I/usr/local/php/include/php -I/usr/local/php/include/php/main -I/usr/local/php/include/php/TSRM -I/usr/local/php/include/php/Zend -I/usr/local/php/include/php/ext -I/usr/local/php/include/php/ext/date/lib -I/usr/local/rabbitmq-c-0.8.0//include  -DHAVE_CONFIG_H  -g -O2   -c /usr/local/src/amqp-1.9.3/amqp_exchange.c -o amqp_exchange.lo 
 cc -I. -I/usr/local/src/amqp-1.9.3 -DPHP_ATOM_INC -I/usr/local/src/amqp-1.9.3/include -I/usr/local/src/amqp-1.9.3/main -I/usr/local/src/amqp-1.9.3 -I/usr/local/php/include/php -I/usr/local/php/include/php/main -I/usr/local/php/include/php/TSRM -I/usr/local/php/include/php/Zend -I/usr/local/php/include/php/ext -I/usr/local/php/include/php/ext/date/lib -I/usr/local/rabbitmq-c-0.8.0//include -DHAVE_CONFIG_H -g -O2 -c /usr/local/src/amqp-1.9.3/amqp_exchange.c  -fPIC -DPIC -o .libs/amqp_exchange.o
/bin/sh /usr/local/src/amqp-1.9.3/libtool --mode=compile cc  -I. -I/usr/local/src/amqp-1.9.3 -DPHP_ATOM_INC -I/usr/local/src/amqp-1.9.3/include -I/usr/local/src/amqp-1.9.3/main -I/usr/local/src/amqp-1.9.3 -I/usr/local/php/include/php -I/usr/local/php/include/php/main -I/usr/local/php/include/php/TSRM -I/usr/local/php/include/php/Zend -I/usr/local/php/include/php/ext -I/usr/local/php/include/php/ext/date/lib -I/usr/local/rabbitmq-c-0.8.0//include  -DHAVE_CONFIG_H  -g -O2   -c /usr/local/src/amqp-1.9.3/amqp_queue.c -o amqp_queue.lo 
 cc -I. -I/usr/local/src/amqp-1.9.3 -DPHP_ATOM_INC -I/usr/local/src/amqp-1.9.3/include -I/usr/local/src/amqp-1.9.3/main -I/usr/local/src/amqp-1.9.3 -I/usr/local/php/include/php -I/usr/local/php/include/php/main -I/usr/local/php/include/php/TSRM -I/usr/local/php/include/php/Zend -I/usr/local/php/include/php/ext -I/usr/local/php/include/php/ext/date/lib -I/usr/local/rabbitmq-c-0.8.0//include -DHAVE_CONFIG_H -g -O2 -c /usr/local/src/amqp-1.9.3/amqp_queue.c  -fPIC -DPIC -o .libs/amqp_queue.o
/bin/sh /usr/local/src/amqp-1.9.3/libtool --mode=compile cc  -I. -I/usr/local/src/amqp-1.9.3 -DPHP_ATOM_INC -I/usr/local/src/amqp-1.9.3/include -I/usr/local/src/amqp-1.9.3/main -I/usr/local/src/amqp-1.9.3 -I/usr/local/php/include/php -I/usr/local/php/include/php/main -I/usr/local/php/include/php/TSRM -I/usr/local/php/include/php/Zend -I/usr/local/php/include/php/ext -I/usr/local/php/include/php/ext/date/lib -I/usr/local/rabbitmq-c-0.8.0//include  -DHAVE_CONFIG_H  -g -O2   -c /usr/local/src/amqp-1.9.3/amqp_connection.c -o amqp_connection.lo 
 cc -I. -I/usr/local/src/amqp-1.9.3 -DPHP_ATOM_INC -I/usr/local/src/amqp-1.9.3/include -I/usr/local/src/amqp-1.9.3/main -I/usr/local/src/amqp-1.9.3 -I/usr/local/php/include/php -I/usr/local/php/include/php/main -I/usr/local/php/include/php/TSRM -I/usr/local/php/include/php/Zend -I/usr/local/php/include/php/ext -I/usr/local/php/include/php/ext/date/lib -I/usr/local/rabbitmq-c-0.8.0//include -DHAVE_CONFIG_H -g -O2 -c /usr/local/src/amqp-1.9.3/amqp_connection.c  -fPIC -DPIC -o .libs/amqp_connection.o
/bin/sh /usr/local/src/amqp-1.9.3/libtool --mode=compile cc  -I. -I/usr/local/src/amqp-1.9.3 -DPHP_ATOM_INC -I/usr/local/src/amqp-1.9.3/include -I/usr/local/src/amqp-1.9.3/main -I/usr/local/src/amqp-1.9.3 -I/usr/local/php/include/php -I/usr/local/php/include/php/main -I/usr/local/php/include/php/TSRM -I/usr/local/php/include/php/Zend -I/usr/local/php/include/php/ext -I/usr/local/php/include/php/ext/date/lib -I/usr/local/rabbitmq-c-0.8.0//include  -DHAVE_CONFIG_H  -g -O2   -c /usr/local/src/amqp-1.9.3/amqp_connection_resource.c -o amqp_connection_resource.lo 
 cc -I. -I/usr/local/src/amqp-1.9.3 -DPHP_ATOM_INC -I/usr/local/src/amqp-1.9.3/include -I/usr/local/src/amqp-1.9.3/main -I/usr/local/src/amqp-1.9.3 -I/usr/local/php/include/php -I/usr/local/php/include/php/main -I/usr/local/php/include/php/TSRM -I/usr/local/php/include/php/Zend -I/usr/local/php/include/php/ext -I/usr/local/php/include/php/ext/date/lib -I/usr/local/rabbitmq-c-0.8.0//include -DHAVE_CONFIG_H -g -O2 -c /usr/local/src/amqp-1.9.3/amqp_connection_resource.c  -fPIC -DPIC -o .libs/amqp_connection_resource.o
/bin/sh /usr/local/src/amqp-1.9.3/libtool --mode=compile cc  -I. -I/usr/local/src/amqp-1.9.3 -DPHP_ATOM_INC -I/usr/local/src/amqp-1.9.3/include -I/usr/local/src/amqp-1.9.3/main -I/usr/local/src/amqp-1.9.3 -I/usr/local/php/include/php -I/usr/local/php/include/php/main -I/usr/local/php/include/php/TSRM -I/usr/local/php/include/php/Zend -I/usr/local/php/include/php/ext -I/usr/local/php/include/php/ext/date/lib -I/usr/local/rabbitmq-c-0.8.0//include  -DHAVE_CONFIG_H  -g -O2   -c /usr/local/src/amqp-1.9.3/amqp_channel.c -o amqp_channel.lo 
 cc -I. -I/usr/local/src/amqp-1.9.3 -DPHP_ATOM_INC -I/usr/local/src/amqp-1.9.3/include -I/usr/local/src/amqp-1.9.3/main -I/usr/local/src/amqp-1.9.3 -I/usr/local/php/include/php -I/usr/local/php/include/php/main -I/usr/local/php/include/php/TSRM -I/usr/local/php/include/php/Zend -I/usr/local/php/include/php/ext -I/usr/local/php/include/php/ext/date/lib -I/usr/local/rabbitmq-c-0.8.0//include -DHAVE_CONFIG_H -g -O2 -c /usr/local/src/amqp-1.9.3/amqp_channel.c  -fPIC -DPIC -o .libs/amqp_channel.o
/bin/sh /usr/local/src/amqp-1.9.3/libtool --mode=compile cc  -I. -I/usr/local/src/amqp-1.9.3 -DPHP_ATOM_INC -I/usr/local/src/amqp-1.9.3/include -I/usr/local/src/amqp-1.9.3/main -I/usr/local/src/amqp-1.9.3 -I/usr/local/php/include/php -I/usr/local/php/include/php/main -I/usr/local/php/include/php/TSRM -I/usr/local/php/include/php/Zend -I/usr/local/php/include/php/ext -I/usr/local/php/include/php/ext/date/lib -I/usr/local/rabbitmq-c-0.8.0//include  -DHAVE_CONFIG_H  -g -O2   -c /usr/local/src/amqp-1.9.3/amqp_envelope.c -o amqp_envelope.lo 
 cc -I. -I/usr/local/src/amqp-1.9.3 -DPHP_ATOM_INC -I/usr/local/src/amqp-1.9.3/include -I/usr/local/src/amqp-1.9.3/main -I/usr/local/src/amqp-1.9.3 -I/usr/local/php/include/php -I/usr/local/php/include/php/main -I/usr/local/php/include/php/TSRM -I/usr/local/php/include/php/Zend -I/usr/local/php/include/php/ext -I/usr/local/php/include/php/ext/date/lib -I/usr/local/rabbitmq-c-0.8.0//include -DHAVE_CONFIG_H -g -O2 -c /usr/local/src/amqp-1.9.3/amqp_envelope.c  -fPIC -DPIC -o .libs/amqp_envelope.o
/bin/sh /usr/local/src/amqp-1.9.3/libtool --mode=compile cc  -I. -I/usr/local/src/amqp-1.9.3 -DPHP_ATOM_INC -I/usr/local/src/amqp-1.9.3/include -I/usr/local/src/amqp-1.9.3/main -I/usr/local/src/amqp-1.9.3 -I/usr/local/php/include/php -I/usr/local/php/include/php/main -I/usr/local/php/include/php/TSRM -I/usr/local/php/include/php/Zend -I/usr/local/php/include/php/ext -I/usr/local/php/include/php/ext/date/lib -I/usr/local/rabbitmq-c-0.8.0//include  -DHAVE_CONFIG_H  -g -O2   -c /usr/local/src/amqp-1.9.3/amqp_basic_properties.c -o amqp_basic_properties.lo 
 cc -I. -I/usr/local/src/amqp-1.9.3 -DPHP_ATOM_INC -I/usr/local/src/amqp-1.9.3/include -I/usr/local/src/amqp-1.9.3/main -I/usr/local/src/amqp-1.9.3 -I/usr/local/php/include/php -I/usr/local/php/include/php/main -I/usr/local/php/include/php/TSRM -I/usr/local/php/include/php/Zend -I/usr/local/php/include/php/ext -I/usr/local/php/include/php/ext/date/lib -I/usr/local/rabbitmq-c-0.8.0//include -DHAVE_CONFIG_H -g -O2 -c /usr/local/src/amqp-1.9.3/amqp_basic_properties.c  -fPIC -DPIC -o .libs/amqp_basic_properties.o
/bin/sh /usr/local/src/amqp-1.9.3/libtool --mode=compile cc  -I. -I/usr/local/src/amqp-1.9.3 -DPHP_ATOM_INC -I/usr/local/src/amqp-1.9.3/include -I/usr/local/src/amqp-1.9.3/main -I/usr/local/src/amqp-1.9.3 -I/usr/local/php/include/php -I/usr/local/php/include/php/main -I/usr/local/php/include/php/TSRM -I/usr/local/php/include/php/Zend -I/usr/local/php/include/php/ext -I/usr/local/php/include/php/ext/date/lib -I/usr/local/rabbitmq-c-0.8.0//include  -DHAVE_CONFIG_H  -g -O2   -c /usr/local/src/amqp-1.9.3/amqp_methods_handling.c -o amqp_methods_handling.lo 
 cc -I. -I/usr/local/src/amqp-1.9.3 -DPHP_ATOM_INC -I/usr/local/src/amqp-1.9.3/include -I/usr/local/src/amqp-1.9.3/main -I/usr/local/src/amqp-1.9.3 -I/usr/local/php/include/php -I/usr/local/php/include/php/main -I/usr/local/php/include/php/TSRM -I/usr/local/php/include/php/Zend -I/usr/local/php/include/php/ext -I/usr/local/php/include/php/ext/date/lib -I/usr/local/rabbitmq-c-0.8.0//include -DHAVE_CONFIG_H -g -O2 -c /usr/local/src/amqp-1.9.3/amqp_methods_handling.c  -fPIC -DPIC -o .libs/amqp_methods_handling.o
/bin/sh /usr/local/src/amqp-1.9.3/libtool --mode=compile cc  -I. -I/usr/local/src/amqp-1.9.3 -DPHP_ATOM_INC -I/usr/local/src/amqp-1.9.3/include -I/usr/local/src/amqp-1.9.3/main -I/usr/local/src/amqp-1.9.3 -I/usr/local/php/include/php -I/usr/local/php/include/php/main -I/usr/local/php/include/php/TSRM -I/usr/local/php/include/php/Zend -I/usr/local/php/include/php/ext -I/usr/local/php/include/php/ext/date/lib -I/usr/local/rabbitmq-c-0.8.0//include  -DHAVE_CONFIG_H  -g -O2   -c /usr/local/src/amqp-1.9.3/amqp_timestamp.c -o amqp_timestamp.lo 
 cc -I. -I/usr/local/src/amqp-1.9.3 -DPHP_ATOM_INC -I/usr/local/src/amqp-1.9.3/include -I/usr/local/src/amqp-1.9.3/main -I/usr/local/src/amqp-1.9.3 -I/usr/local/php/include/php -I/usr/local/php/include/php/main -I/usr/local/php/include/php/TSRM -I/usr/local/php/include/php/Zend -I/usr/local/php/include/php/ext -I/usr/local/php/include/php/ext/date/lib -I/usr/local/rabbitmq-c-0.8.0//include -DHAVE_CONFIG_H -g -O2 -c /usr/local/src/amqp-1.9.3/amqp_timestamp.c  -fPIC -DPIC -o .libs/amqp_timestamp.o
/bin/sh /usr/local/src/amqp-1.9.3/libtool --mode=compile cc  -I. -I/usr/local/src/amqp-1.9.3 -DPHP_ATOM_INC -I/usr/local/src/amqp-1.9.3/include -I/usr/local/src/amqp-1.9.3/main -I/usr/local/src/amqp-1.9.3 -I/usr/local/php/include/php -I/usr/local/php/include/php/main -I/usr/local/php/include/php/TSRM -I/usr/local/php/include/php/Zend -I/usr/local/php/include/php/ext -I/usr/local/php/include/php/ext/date/lib -I/usr/local/rabbitmq-c-0.8.0//include  -DHAVE_CONFIG_H  -g -O2   -c /usr/local/src/amqp-1.9.3/amqp_decimal.c -o amqp_decimal.lo 
 cc -I. -I/usr/local/src/amqp-1.9.3 -DPHP_ATOM_INC -I/usr/local/src/amqp-1.9.3/include -I/usr/local/src/amqp-1.9.3/main -I/usr/local/src/amqp-1.9.3 -I/usr/local/php/include/php -I/usr/local/php/include/php/main -I/usr/local/php/include/php/TSRM -I/usr/local/php/include/php/Zend -I/usr/local/php/include/php/ext -I/usr/local/php/include/php/ext/date/lib -I/usr/local/rabbitmq-c-0.8.0//include -DHAVE_CONFIG_H -g -O2 -c /usr/local/src/amqp-1.9.3/amqp_decimal.c  -fPIC -DPIC -o .libs/amqp_decimal.o
/bin/sh /usr/local/src/amqp-1.9.3/libtool --mode=link cc -DPHP_ATOM_INC -I/usr/local/src/amqp-1.9.3/include -I/usr/local/src/amqp-1.9.3/main -I/usr/local/src/amqp-1.9.3 -I/usr/local/php/include/php -I/usr/local/php/include/php/main -I/usr/local/php/include/php/TSRM -I/usr/local/php/include/php/Zend -I/usr/local/php/include/php/ext -I/usr/local/php/include/php/ext/date/lib -I/usr/local/rabbitmq-c-0.8.0//include  -DHAVE_CONFIG_H  -g -O2   -o amqp.la -export-dynamic -avoid-version -prefer-pic -module -rpath /usr/local/src/amqp-1.9.3/modules  amqp.lo amqp_type.lo amqp_exchange.lo amqp_queue.lo amqp_connection.lo amqp_connection_resource.lo amqp_channel.lo amqp_envelope.lo amqp_basic_properties.lo amqp_methods_handling.lo amqp_timestamp.lo amqp_decimal.lo -Wl,-rpath,/usr/local/rabbitmq-c-0.8.0//lib -L/usr/local/rabbitmq-c-0.8.0//lib -lrabbitmq
cc -shared  .libs/amqp.o .libs/amqp_type.o .libs/amqp_exchange.o .libs/amqp_queue.o .libs/amqp_connection.o .libs/amqp_connection_resource.o .libs/amqp_channel.o .libs/amqp_envelope.o .libs/amqp_basic_properties.o .libs/amqp_methods_handling.o .libs/amqp_timestamp.o .libs/amqp_decimal.o  -Wl,--rpath -Wl,/usr/local/rabbitmq-c-0.8.0/lib -Wl,--rpath -Wl,/usr/local/rabbitmq-c-0.8.0/lib -L/usr/local/rabbitmq-c-0.8.0//lib /usr/local/rabbitmq-c-0.8.0/lib/librabbitmq.so  -Wl,-rpath -Wl,/usr/local/rabbitmq-c-0.8.0//lib -Wl,-soname -Wl,amqp.so -o .libs/amqp.so
creating amqp.la
(cd .libs && rm -f amqp.la && ln -s ../amqp.la amqp.la)
/bin/sh /usr/local/src/amqp-1.9.3/libtool --mode=install cp ./amqp.la /usr/local/src/amqp-1.9.3/modules
cp ./.libs/amqp.so /usr/local/src/amqp-1.9.3/modules/amqp.so
cp ./.libs/amqp.lai /usr/local/src/amqp-1.9.3/modules/amqp.la
PATH="$PATH:/sbin" ldconfig -n /usr/local/src/amqp-1.9.3/modules
----------------------------------------------------------------------
Libraries have been installed in:
   /usr/local/src/amqp-1.9.3/modules


If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the `LD_RUN_PATH' environment variable
     during linking
   - use the `-Wl,--rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to `/etc/ld.so.conf'


See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------


Build complete.
Don't forget to run 'make test'.


Installing shared extensions:     /usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/
#配置文件里添加一行extension = amqp.so
[root@localhost amqp-1.9.3]# vim /usr/local/php/lib/php.ini
#重启php和Nginx
/etc/init.d/php-fpm restart

/etc/init.d/nginx restart



##测试(此处参考https://segmentfault.com/a/1190000002963223):

 #publish.php

<?php


/**
 * test rabbitMQ
 */


$conn_args = array(
    'host' => '192.168.121.131',
    'port' => '5672',
    'login' => 'admin',
    'password' => 'admin',
    'vhost' => '/',
);


// create connect
$conn = new AMQPConnection($conn_args);
if (!$conn->connect()) {
    die("can not connect the broker!\n");
}
// 创建信道
$channel = new AMQPChannel($conn);
// 创建交换机
$exchange = new AMQPExchange($channel);
$exchange->setName("pang_exchange");
$exchange->setType(AMQP_EX_TYPE_DIRECT);//direct类型
$exchange->setFlags(AMQP_DURABLE);//持久化
$status = $exchange->declare(); // 声明
echo "exchange status:".$status."\n";
$message = 'Test MQ!';
$route = array('route1', 'route2');
    error_log(date("c")."\t\n", 3, "time.log");
for($i = 0; $i < 100000; $i++){
    echo "Send Message:".$exchange->publish($message.date("Y-m-d H:i:s"), $route[$i%2])."\n";
    // sleep(1);
}

    error_log(date("c")."\t\n", 3, "time.log");


#consume.php

<?php
$conn_args = array(
    'host' => '192.168.121.131',
    'port' => '5672',
    'login' => 'admin',
    'password' => 'admin',
    'vhost' => '/',
);


// create connect
$conn = new AMQPConnection($conn_args);
if (!$conn->connect()) {
    die("can not connect the broker!\n");
}
// 创建信道
$channel = new AMQPChannel($conn);
// 创建交换机
$exchange = new AMQPExchange($channel);
$exchange_name = "pang_exchange";
$exchange->setName($exchange_name);
$exchange->setType(AMQP_EX_TYPE_DIRECT);//direct类型
$exchange->setFlags(AMQP_DURABLE);//持久化
$exchange->declare(); // 声明
// 创建队列
$queue_name = 'p_queue';
$queue = new AMQPQueue($channel);
$queue->setName($queue_name);
$queue->setFlags(AMQP_DURABLE); // 持久化
$queue->declare();


// 绑定交换机与队列,并指定路由键
echo 'Queue Bind '.$queue->bind($exchange_name, 'route1')."\n";
echo 'Queue Bind '.$queue->bind($exchange_name, 'route2')."\n";


// 阻塞模式接收消息
echo "Message:\n";
$queue->consume('processMessage', AMQP_AUTOACK); // 自动ACK应答


$conn->disconnect();


/**
 * 消费回调函数 处理消息
 */
function processMessage($envelope, $queue) {
    $msg = $envelope->getBody();
    echo date("c")."\t".$envelope->getRoutingKey()."\t\n processMessage:".$msg."\n"; // 处理消息
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: 在Linux安装RabbitMQ,可以按照以下步骤进行: 1. 首先,需要安装Erlang环境,因为RabbitMQ是基于Erlang语言开发的。可以使用以下命令安装: sudo apt-get install erlang 2. 接着,需要下载RabbitMQ安装包。可以从官网下载最新版本的安装包,也可以使用以下命令下载: wget https://github.com/rabbitmq/rabbitmq-server/releases/download/v3.8.9/rabbitmq-server-generic-unix-3.8.9.tar.xz 3. 下载完成后,解压缩安装包: tar -xvf rabbitmq-server-generic-unix-3.8.9.tar.xz 4. 进入解压缩后的目录,执行以下命令安装: sudo ./sbin/rabbitmq-server 5. 安装完成后,可以使用以下命令启动RabbitMQ服务: sudo systemctl start rabbitmq-server 6. 如果需要设置RabbitMQ开机自启动,可以使用以下命令: sudo systemctl enable rabbitmq-server 7. 最后,可以使用以下命令检查RabbitMQ服务是否正常运行: sudo systemctl status rabbitmq-server 以上就是在Linux安装RabbitMQ的步骤。 ### 回答2: 要在Linux安装RabbitMQ,首先需要确保系统已安装Erlang/OTP,因为RabbitMQ是使用Erlang编写的。可以使用以下命令安装Erlang/OTP: 1.更新系统软件包列表:sudo apt-get update 2.安装Erlang/OTP:sudo apt-get install erlang 安装完Erlang/OTP后,可以按照以下步骤安装RabbitMQ: 1.从RabbitMQ官方网站(https://www.rabbitmq.com/download.html)下载适用于LinuxRabbitMQ安装包。选择适合你Linux发行版本的安装包。 2.将下载的文件复制到你想要安装RabbitMQ的目录。例如,将文件复制到/usr/local/目录。 3.解压缩安装包:sudo tar -zxvf rabbitmq-server-generic-unix-x.x.x.tar.gz (请将"x.x.x"替换为你下载的RabbitMQ版本号) 4.重命名解压缩出来的文件夹:sudo mv rabbitmq_server-x.x.x/ rabbitmq 5.将RabbitMQ所在的sbin目录添加到系统的PATH环境变量中:export PATH=$PATH:/usr/local/rabbitmq/sbin 6.执行以下命令,创建RabbitMQ所需的目录:sudo mkdir /var/lib/rabbitmq sudo chown -R rabbitmq:rabbitmq /var/lib/rabbitmq 7.为RabbitMQ创建一个配置文件:sudo nano /etc/rabbitmq/rabbitmq.conf 8.在打开的配置文件中输入以下内容: NODENAME=rabbit@localhost NODE_PORT=5672 CONFIG_FILE=/etc/rabbitmq/rabbitmq CONFIG_FILE_VERSION=2 9.保存并退出配置文件。 10.启动RabbitMQ服务:sudo rabbitmq-server -detached 11.检查RabbitMQ是否成功启动:sudo rabbitmqctl status 如果成功安装和启动RabbitMQ,你应该能看到类似于"{rabbit,\[rabbit@localhost\],\[persistent\_mode\]}\n"的输出。 现在,RabbitMQ已经成功安装在你的Linux系统中,你可以使用它来建立分布式应用程序之间的通信。 ### 回答3: 在Linux安装rabbitmq可以按照以下步骤进行: 1. 首先,确保已经安装了Erlang/OTP(Open Telecom Platform),因为RabbitMQ是使用Erlang编写的。可以通过使用以下命令来安装Erlang: ``` sudo apt install erlang ``` 2. 接下来,需要下载并安装RabbitMQ包管理系统。可以从RabbitMQ官方网站下载最新版本的软件包。 ``` wget https://github.com/rabbitmq/rabbitmq-server/releases/download/v3.9.5/rabbitmq-server-3.9.5-1.noarch.rpm ``` 3. 安装RabbitMQ软件包。 ``` sudo rpm -Uvh rabbitmq-server-3.9.5-1.noarch.rpm ``` 4. 启动RabbitMQ服务。 ``` sudo systemctl start rabbitmq-server ``` 5. 验证RabbitMQ服务是否成功启动。 ``` sudo systemctl status rabbitmq-server ``` 如果显示"active (running)",则表示RabbitMQ已经成功安装并且正在运行。 6. 可以通过RabbitMQ的Web图形界面管理工具访问RabbitMQ服务器,默认情况下,它监听在端口15672上。在浏览器中输入`http://localhost:15672`并使用默认的登录凭据(用户名:guest,密码:guest)登录。 以上就是在Linux安装RabbitMQ的简单步骤。在安装完成后,你可以配置RabbitMQ以满足你的特定需求,并开始使用它来构建可靠的消息队列系统。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值