用于ubuntu的默认源里面没有php5-amqp这个包,所以要用上amqp得考手动编译。

参考手册 http://php.net/manual/pl/book.amqp.php

首先安装必须的php编译工具

  1. sudo apt-get install php5-dev

安装rabbitmq的库

  1. sudo apt-get install librabbitmq-dev

如果你的Linux发行版没有现成的librabbitmq-dev包,那么可以通过下载源码编译安装
然后如果你没有安装git话请安装一下git,因为我们要从官方的版本库中获取源代码
# 克隆源码并编译

  1. git clone git://github.com/alanxz/rabbitmq-c.git
  2. cd rabbitmq-c
  3. git submodule init
  4. git submodule update

# 编译库

  1. autoreconf -i && ./configure && make && sudo make install

然后我们需要去下载php扩展的源代码,地址在此:http://pecl.php.net/package/amqp

当前最新版本为1.0.10

  1. wget http://pecl.php.net/get/amqp-1.0.10.tgz
  2. tar zxf amqp-1.0.10.tgz
  3. cd amqp-1.0.10/
  4. phpize && ./configure --with-amqp && make && sudo make install

如果报错

  1. /root/amqp-1.0.9/amqp_queue.c: In function ‘read_message_from_channel’:
  2. /root/amqp-1.0.9/amqp_queue.c:341:11: error: ‘AMQP_FIELD_KIND_U64’ undeclared (first use in this function)
  3. /root/amqp-1.0.9/amqp_queue.c:341:11: note: each undeclared identifier is reported only once for each function it appears in
  4. /root/amqp-1.0.9/amqp_queue.c: In function ‘zim_amqp_queue_class_nack’:
  5. /root/amqp-1.0.9/amqp_queue.c:1093:2: error: unknown type name ‘amqp_basic_nack_t’
  6. /root/amqp-1.0.9/amqp_queue.c:1113:3: error: request for member ‘delivery_tag’ in something not a structure or union
  7. /root/amqp-1.0.9/amqp_queue.c:1114:3: error: request for member ‘multiple’ in something not a structure or union
  8. /root/amqp-1.0.9/amqp_queue.c:1115:3: error: request for member ‘requeue’ in something not a structure or union
  9. /root/amqp-1.0.9/amqp_queue.c:1120:3: error: ‘AMQP_BASIC_NACK_METHOD’ undeclared (first use in this function)
  10. make: *** [amqp_queue.lo] Error 1

是因为默认的librabbitmq-dev发行版的包比较旧,用上面git方式编译安装最新即可。

去下载最新的php扩展的源代码,地址在此:http://pecl.php.net/package/amqp

  1. wget http://pecl.php.net/get/amqp-x.x.x.tgz
  2. tar zxf amqp-x.x.x.tgz
  3. cd amqp-x.x.x/
  4. 继续执行
  5. phpize && ./configure --with-amqp && make && sudo make install

最后一步创建配置文件

  1. sudo echo "extension = amqp.so" > /etc/php5/conf.d/amqp.ini

重启web服务器在phpinfo页面中看到以下内容说明安装好了

sudo /etc/init.d/apache2 restart

http://localhost/phpinfo.php

启用rabbitamqp的图形界面

1.在安装amqp的时候会自动安装rabbitmq-plugins

寻找一下rabbitmq-plugins的位置

2.切换到rabbitmq-plugins的当前目录,

比如 cd /usr/lib/rabbitmq/bin

启动插件服务

root@luochangjian-System-Product-Name:/usr/lib/rabbitmq/bin# sudo ./rabbitmq-plugins enable rabbitmq_management
Plugin configuration unchanged.

即完成插件安装。安装完成后重启RabbitMQ,打开浏览器。输入 http://127.0.0.1:55672,打开页面要求输入用户名密码,用默认的guest/guest即可

注:若页面找不到,可通过netstat命令检查下端口号是否正确。

ubuntu下手动安装php-amqp模块教程的更多相关文章

  1. Ubuntu下手动安装vscode

    Ubuntu下手动安装vscode1.下载vscodewget https://vscode.cdn.azure.cn/stable/553cfb2c2205db5f15f3ee8395bbd5cf0 ...

  2. Ubuntu下手动安装NextCloud

    安装环境:阿里云VPS Ubuntu 16.04   一. 安装Apache2 sudo apt-get install apache2 安装完成后,浏览器访问http://your ip/,出现It ...

  3. Linux(ubuntu)下手动安装 firefox 6 并且添加快捷方式图标

    Mozilla 正式发布了Firefox 6,如果你的电脑上还在用非常古老的版本么,赶紧过来更新下吧,由于官网上面只是提供了linux下的.bz2的压缩包,没有deb或者rmp格式,所以需要自己安装下 ...

  4. Ubuntu下手动安装VMware Tools步骤

    To mount the CD image and extract the contents: Power on the virtual machine. Log in to the virtual ...

  5. Ubuntu下手动安装Nvidia显卡驱动

    1. 下载最新版的nVidia驱动. http://www.nvidia.com/page/drivers.html 2.编辑blacklist.conf. sudo gedit /etc/modpr ...

  6. centos或ubuntu下手动安装jdk8

    https://blog.csdn.net/pang_ping/article/details/80570011 https://blog.csdn.net/u012707739/article/de ...

  7. Ubuntu 14.04 下手动安装Firefox的Flash插件

    有时候我们不得不採用手动安装一些软件. Ubuntu 14.04 下手动安装Firefox的Flash插件有下面几步 1. 下载Flash插件 下载地址为http://get.adobe.com/cn ...

  8. Torch7在Ubuntu下的安装与配置

    Torch7的本系列教程的主要目的是介绍Torch的入门使用.今天首先分享一下Torch7的安装.(在Ubuntu14.04安装torch7) 为什么选择Torch Torch的目标是在建立科学算法的 ...

  9. Deepin系统手动安装oracle jdk8详细教程

    Deepin系统手动安装oracle jdk8详细教程 oracle官网下载jdk压缩包,使用 sudo tar -zxf jdk***解压文件,我放在在了home/diy/java/jdk路径下. ...

随机推荐

  1. Struts2中使用HttpServletRequest和HttpServletResponse

    一.非Ioc方式 这种方式主要是利用了com.opensymphony.xwork2.ActionContext类以及org.apache.struts2.ServletActionContext类, ...

  2. 爬虫--Scrapy-持久化存储操作2

    1.管道的高级操作 将爬取到的数据值分别存储到本地磁盘.redis数据库.mysql数据. 需求:将爬取到的数据值分别存储到本地磁盘.redis数据库.mysql数据. 1.需要在管道文件中编写对应平 ...

  3. 【385】itertools 的 product 和 chain 和 accumulate

    参考:itertools模块 product 相当于返回两个集合中数据的所有组合可能 Examples from Eric Martin from itertools import product p ...

  4. adb常用命令及详解

    ADB 即 Android Debug Bridge,Android调试桥.ADB工作方式比较特殊,采用监听Socket TCP 端口的方式让IDE和Qemu通讯,默认情况下adb会daemon相关的 ...

  5. 关于三层(dao,serviece,servlet)

    在登陆校验中, dao:返回的是resultset 对象,就是  ps.executeQuery(需要强化的是jdbc的具体的流程) 其中的数据库连接时可以自己写 可以通过工厂类 可以通过数据库的连接 ...

  6. servlet(1)request常用方法

    HttpServletRequest对象代表客户端的请求,当客户端通过HTTP协议访问服务器时,HTTP请求头中的所有信息都封装在这个对象中,开发人员通过这个对象的方法,可以获得客户这些信息. req ...

  7. mysql 触发器介绍

    create trigger triggerName   after/before insert/update/delete on tableName  for each row   --这句话在my ...

  8. JAVA语言 第二周

    放假第二周了,时间真快! 上一周配置好了环境变量,这一周就可以做一些测试了.对不同的内容分类进行了测试,包括写入.输出.变量·······还有很多.对于开学的试卷,在第一部分做的还行,第二部分就没什么 ...

  9. 理解JVM2 栈内存,方法区,堆内存

    堆,方法区,栈的关系 分配最大堆内存-Xmx32m class SimpleHeap(val id: Int){ fun show() = println("My id is $id&quo ...

  10. justify-content & align-items & align-content

    [justify-content & align-items & align-content] 三个属性均作用于container. justify-content用于控制main-a ...