简体   繁体   English

如何在 windows 上安装 amqp

[英]How to install amqp on windows

I am having this error while installing pecl/amqp我在安装pecl/amqp时遇到这个错误

when I type in the command line: pear install pecl/amqp当我在命令行中输入: pear install pecl/amqp

WARNING: php_bin C:\\xampp\\php.\\php.exe appears to have a suffix .\\php.exe,警告:php_bin C:\\xampp\\php.\\php.exe 似乎有一个后缀 .\\php.exe,

but

config variable php_suffix does not match配置变量 php_suffix 不匹配
ERROR: The DSP amqp.dsp does not exist.错误:DSP amqp.dsp 不存在。

I need to install this so that I can use amqp ( RabbitMQ ) on php.我需要安装它,以便我可以在 php 上使用 amqp ( RabbitMQ )。

@ AMQP installation php.net : @AMQP 安装 php.net :

Note to Windows users: This extension does not currently support Windows since the librabbitmq library does not yet support Windows. Windows 用户注意:此扩展目前不支持 Windows,因为 librabbitmq 库尚不支持 Windows。

But here at RabbitMQ website is a windows installer...但是在 RabbitMQ 网站上有一个 Windows 安装程序...

Apparently the information on the php.net page is outdated显然php.net页面上的信息已过时


To install do like this:要安装这样做:

  1. Download the correct package for your php from this official PECL amqp page这个官方 PECL amqp 页面下载正确的 php 包
  2. unzip解压
  3. add php_amqp.dll to your php ext folder and enable the extension inside your php.ini file: extension=php_amqp.dllphp_amqp.dll添加到你的 php ext文件夹并在你的 php.ini 文件中启用扩展: extension=php_amqp.dll
  4. add rabbitmq.#.dll to your windows system 32 folder (where # corresponds with the version number).rabbitmq.#.dll添加到您的 Windows 系统 32 文件夹(其中 # 对应于版本号)。

All this according to the post on the blog I found here .所有这一切都根据我在这里找到的博客上的帖子。


UPDATE更新

I updated some of the information above.我更新了上面的一些信息。 The blog post is from 2013, and only mentioning older versions, but it is anyway a nice guide to the steps you need to take.这篇博文是 2013 年的,只提到了旧版本,但无论如何它是您需要采取的步骤的一个很好的指南。 Since then newer versions are available so be aware there are some slight differences in the process (mainly version numbers) if you want to install a newer version.从那时起,可以使用更新的版本,因此如果您想安装更新的版本,请注意过程中存在一些细微的差异(主要是版本号)。

This works for me in PHP 7.1, and amqp 1.9.4 for Windows.这适用于 PHP 7.1 和 amqp 1.9.4 适用于 Windows。

  • Download the correct package in https://pecl.php.net/package/amqp based on your PHP version, architecture, thread safety, and compiler.根据您的 PHP 版本、架构、线程安全和编译器,在https://pecl.php.net/package/amqp下载正确的包。 You can check it in phpinfo您可以在 phpinfo 中查看
  • Copy php_amqp.dll to your php ext folder将 php_amqp.dll 复制到你的 php ext 文件夹
  • Update your php.ini with: extension=php_amqp.dll使用以下内容更新您的 php.ini:extension=php_amqp.dll
  • Copy rabbitmq.4.dll to your windows system 32 folder if 32bit system.如果是 32 位系统,请将 rabbitmq.4.dll 复制到您的 windows 系统 32 文件夹中。 add it to SysWOW64 if using 64bit system.如果使用 64 位系统,请将其添加到 SysWOW64。
  • Restart apache.重启阿帕奇。

On Windows 10, build 19041 (2004 update), 64-bit.在 Windows 10 上,内部版本 19041(2004 更新),64 位。

Using Xampp with PHP 7.4.8.在 PHP 7.4.8 中使用 Xampp。

  1. Go to here and download your relevant version: https://pecl.php.net/package/amqp (check which version you need in CLI using php -v )转到这里并下载您的相关版本: https : //pecl.php.net/package/amqp (使用php -v在 CLI 中检查您需要哪个版本)
  2. From the .zip , copy the rabbitmq.#.dll to C:/Windows/System32.zip ,将rabbitmq.#.dll复制到C:/Windows/System32
  3. From the .zip , copy the php_amqp.dll to C:/xampp/php/ext (or simply your php/ext folder if using something else than Xampp).zip ,将php_amqp.dll复制到C:/xampp/php/ext (或者如果使用 Xampp 以外的其他东西,则只是你的php/ext文件夹)

If you've got PHP running as a service with Apache, restart Apache.如果您已将 PHP 作为服务与 Apache 一起运行,请重新启动 Apache。 If you're using it via CLI (eg via Bash and/or Symfony CLI server) then you're already good to go.如果您通过 CLI(例如通过 Bash 和/或 Symfony CLI 服务器)使用它,那么您已经可以开始使用了。


Other posts mention the 64-bit variant to have the rabbitmq.#.dll (where # is the version) to go in C:/Windows/SysWOW64 .其他帖子提到 64 位变体让rabbitmq.#.dll (其中#是版本)进入C:/Windows/SysWOW64 I tried that, didn't work for me, even though running 64-bit Windows and PHP.我试过了,对我不起作用,即使运行 64 位 Windows 和 PHP。

$ php -v
PHP 7.4.8 (cli) (built: Jul  9 2020 11:30:39) ( ZTS Visual C++ 2017 x64 )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies

虽然这不会回答如何使用 pear install pecl/amqp 安装 RabbitMQ,但是您是否尝试过将 rabbitmq 与纯 php 实现php-amqplib 一起使用

After many hours of search: To install amqp to php7.4 & Windows 10 ( https://pecl.php.net/package/amqp ),经过数小时的搜索:将 amqp 安装到 php7.4 和 Windows 10 ( https://pecl.php.net/package/amqp ),

  1. Choose the good file (x86,x64,ts,nts)选择好的文件 (x86,x64,ts,nts)
    php -i or phpinfo() (Architecture => x64) php -i 或 phpinfo()(架构 => x64)
    php -i|findstr "Thread" (ts or nts enable) php -i|findstr "Thread" (ts 或 nts 启用)

  2. Copy复制
    rabbitmq.4.dll and rabbitmq.4.pdb files to PHP root folder rabbitmq.4.dll 和 rabbitmq.4.pdb 文件到 PHP 根文件夹
    php_amqp.dll and php_amqp.pdb files to PHP\\ext folder php_amqp.dll 和 php_amqp.pdb 文件到 PHP\\ext 文件夹

  3. Add extension=amqp to the php.ini file在 php.ini 文件中添加 extension=amqp

  4. check php -m if you show amqp (php -v to show errors)检查 php -m 如果你显示 amqp (php -v 显示错误)

Big thank's to Rezende ( tutorial )非常感谢 Rezende( 教程

If you are on Windows , on this Url you can download the installable rabbitmq and here is the direct download link for RabbitMQ 3.9.11 .如果您使用的是Windows ,您可以在此 URL上下载可安装的rabbitmq ,这里是RabbitMQ 3.9.11的直接下载链接。

You can also use choco to install it using:您还可以使用choco来安装它:

choco install rabbitmq

And since, rabbitmq is implemented/written in erlang you also need erlang to be able to install rabbitmq and its services.由于rabbitmq是用erlang实现/编写的,因此您还需要erlang才能安装rabbitmq及其服务。 Make sure you download erlang and install it.确保下载erlang并安装它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM