php 安装rabbitmq拓展_【RabbitMQ】——centos7安装rabbitmq教程 以及 PHP开启rabbitmq扩展...

第一步:安装Erlang

因为rabbitMQ是Erlang语言编写的,所以我们首先需要安装Erlang

rpm -Uvh http://www.rabbitmq.com/releases/erlang/erlang-18.1-1.el7.centos.x86_64.rpm

第二步、安装rabbitMQ-server

官网提供的安装方式:

rpm --import https://www.rabbitmq.com/rabbitmq-signing-key-public.asc

yum install rabbitmq-server-3.5.6-1.noarch.rpm

第三步、查看rabbitmq-server是否已经安装好了,能查到说明已经安装完成了。

rpm -qa|grep rabbitmq

cc747d29b53e1da6f7602036b40a59fe.png

第四步、开启rabbit-server

service rabbitmq-server start

11dd7e52331e6381bcde189f4961294a.png

第五步、关闭rabbit-server(验证命令)

service rabbitmq-server stop

3a7cade2f300e54b3e9eba39e79d70a9.png

第六步、查看状态

rabbitmqctl status

php 安装rabbitmq拓展_【RabbitMQ】——centos7安装rabbitmq教程 以及 PHP开启rabbitmq扩展..._第1张图片

这样虽然我们已经将rabbitmq的服务正常启动了,但是我们在物理机的浏览器中输入ip:15672时,并不能连接,因为我们还没有配置维护插件和开启远程连接

第七步、安装命令维护插件

rabbitmq-plugins enable rabbitmq_management

第八步、设置配置文件,并开启用户远程访问

1、新建配置文件

vi /etc/rabbitmq/rabbitmq.conf

#默认用户名

default_user = guest

#默认密码

default_pass = guest

#远程用户访问

loopback_users = none

2、启动rabbitmq服务

/sbin/service rabbitmq-server start

3、查看运行

[root@localhost opt]# /sbin/service rabbitmq-server status

Redirecting to /bin/systemctl status rabbitmq-server.service

● rabbitmq-server.service - RabbitMQ broker

Loaded: loaded (/usr/lib/systemd/system/rabbitmq-server.service; enabled; vendor preset: disabled)

Active: activating (start) since Fri 2018-07-06 01:06:31 EDT; 1min 15s ago

Main PID: 2948 (beam.smp)

CGroup: /system.slice/rabbitmq-server.service

├─2948 /usr/lib/erlang/erts-10.0/bin/beam.smp -W w -A 64 -MBas ageffcbf -MHas ageffcbf -MBlmbcs 512 -MHlmbcs...

├─3121 /usr/lib/erlang/erts-10.0/bin/epmd -daemon

├─3259 erl_child_setup 1024

├─3296 inet_gethost 4

└─3297 inet_gethost 4

Jul 06 01:06:36 localhost.localdomain rabbitmq-server[2948]: ## ## RabbitMQ 3.7.7. Copyright (C) 2007-2018 Pi...Inc.

Jul 06 01:06:36 localhost.localdomain rabbitmq-server[2948]: ########## Licensed under the MPL. See http://www.ra...com/

Jul 06 01:06:36 localhost.localdomain rabbitmq-server[2948]: ###### ##

Jul 06 01:06:36 localhost.localdomain rabbitmq-server[2948]: ########## Logs: /var/log/rabbitmq/[email protected]

Jul 06 01:06:36 localhost.localdomain rabbitmq-server[2948]: /var/log/rabbitmq/rabbit@localhost_upgrade.log

Jul 06 01:06:36 localhost.localdomain rabbitmq-server[2948]: Starting broker...

Jul 06 01:06:36 localhost.localdomain rabbitmq-server[2948]: systemd unit for activation check: "rabbitmq-server.service"

Jul 06 01:06:36 localhost.localdomain rabbitmq-server[2948]: Failed to start socat error:enoent

Jul 06 01:06:36 localhost.localdomain rabbitmq-server[2948]: systemd READY notification failed, beware of timeouts

Jul 06 01:06:36 localhost.localdomain rabbitmq-server[2948]: completed with 0 plugins.

Hint: Some lines were ellipsized, use -l to show in full.

4、开启RabbitMQ web访问

rabbitmq-plugins enable rabbitmq_management

/sbin/service rabbitmq-server stop

/sbin/service rabbitmq-server start

5、开启端口15672,5672

[root@localhost opt]# firewall-cmd --permanent --add-port=15672/tcp

success

[root@localhost opt]# firewall-cmd --permanent --add-port=5672/tcp

success

[root@localhost opt]# service network restart

Restarting network (via systemctl): [ OK ]

[root@localhost opt]#

5、设置开机启动

chkconfig rabbitmq-server on

安装完毕web访问

浏览器输入

192.168.x.x:15672

默认账号密码

guest

guest

另一种配置远程访问的方法

#cd /etc/rabbitmq

#cp /usr/share/doc/rabbitmq-server-3.5.6/rabbitmq.config.example /etc/rabbitmq/

#mv rabbitmq.config.example rabbitmq.config

vi /etc/rabbitmq/rabbitmq.config

php 安装rabbitmq拓展_【RabbitMQ】——centos7安装rabbitmq教程 以及 PHP开启rabbitmq扩展..._第2张图片

重启

service rabbitmq-server restart

PHP安装rabbitmq扩展需要安装rabbitmq-c

安装rabbitmq-c

tar zxf rabbitmq-c-0.8.0.tar.gz

cd rabbitmq-c-0.8.0

./configure --prefix=/usr/local/rabbitmq-c-0.8.0

make && make install

安装amqp

tar zxf amqp-1.9.3.tgz

cd amqp-1.9.3

/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 installl

配置amqp扩展

vi /usr/local/php/etc/php.ini

添加 extension=amqp.so

你可能感兴趣的:(php,安装rabbitmq拓展)