27

I wanted to install amqp with pecl for my mac sierra.

I installed php with brew, with pecl install amqp I receive an error: checking for amqp using pkg-config... configure: error: librabbitmq not found

I installed with brew the librabbitmq-c package but I still get this error. I think it's somehow not synced with the pkg-config.

Does someone have an idea what to do here?

ghostika
  • 1,473
  • 1
  • 12
  • 23

8 Answers8

94

First install rabbitmq-c with brew:

brew search librabbitmq
No formula or cask found for "librabbitmq".
Closed pull requests:
Add rabbitmq-c (aka librabbitmq) formula (https://github.com/Homebrew/legacy-homebrew/pull/13437)


brew install rabbitmq-c

Then install amqp with pecl:

pecl install amqp

Set the path to librabbitmq:

Set the path to librabbitmq install prefix [autodetect] : /usr/local/Cellar/rabbitmq-c/0.9.0

Verify that amqp is now installed:

php -i|grep amqp
José Monagas
  • 941
  • 6
  • 4
  • 1
    Although `php -i | grep amqp` didn't return any info confirming amqp was enabled, I was able to use it. – dmmd Dec 06 '18 at 15:20
  • 1
    @dmd Maybe you forgot to add extension=amqp.so; to you php.ini file Pecl do it automatically but you must specify the location of your php.ini To set the location: pecl config-set php_ini /usr/local/etc/php/7.xxx/php.ini Check php.ini location file : php --ini – Fr4NgUs May 11 '19 at 12:17
  • php -m | grep amqp – tlorens Apr 30 '20 at 02:18
  • @jose answer worked for me on MacOS Big Sur with PHP 7.2. – rashidkhan Mar 10 '21 at 00:36
  • 2
    Works fine on Big Sur, just path to cellar has changed: /opt/homebrew/Cellar/rabbitmq-c/0.11.0 – David Apr 06 '21 at 19:31
6

Thanks for this walk through, it was super helpful. Just a quick note, in Mac OS 12.0.1 Monterey, the default install path for rabbitmq in homebrew is:

/opt/homebrew/Cellar/rabbitmq-c/0.11.0
wetmarble
  • 185
  • 1
  • 6
3

I'm on MacOS High Sierra. I installed the Command_line_Tools_macOS_10.13_for_Xcode_10.1.dmg from developer.apple.com and brew installed php 8.

For the amqp extension, I used:

brew install rabbitmq-c
pecl install amqp-1.11.0beta

at the prompt

Set the path to librabbitmq install prefix [autodetect] :

I entered:

Set the path to librabbitmq install prefix [autodetect] : /usr/local/Cellar/rabbitmq-c/0.11.0

robocoder
  • 233
  • 4
  • 9
2

The issue lies with pkg-config not being able to generate libs/cflags for librabbitmq.

$ pkg-config librabbitmq --cflags
Package openssl was not found in the pkg-config search path.
Perhaps you should add the directory containing `openssl.pc'
to the PKG_CONFIG_PATH environment variable
Package 'openssl', required by 'librabbitmq', not found

What I did was to add both rabbitmq-c and openssl to $PKG_CONFIG_PATH as below:

export PKG_CONFIG_PATH="/usr/local/Cellar/rabbitmq-c/0.10.0/lib/pkgconfig:/usr/local/opt/openssl@1.1/lib/pkgconfig"

Then the build will succeed. (Note: I built mine with phpbrew rather than pecl, but should work).

1

Brew doesn't add the file to the pkg-config path, so it needed a command: export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:/usr/local/Cellar/rabbitmq-c/0.9.0/lib/pkgconfig"

ghostika
  • 1,473
  • 1
  • 12
  • 23
1

Before installing make sure the taps are up-to-date:

brew update

Then, install RabbitMQ server with:

brew install rabbitmq

In case that directory is not in PATH it's recommended to append it:

export PATH=$PATH:/usr/local/sbin
0

It's a combination of question and both previous answers which worked for me.

First install RabbitMQ through brew as rabbitmq-c. Then with PECL but add the config path when asked: /usr/local/Cellar/rabbitmq-c/0.10.0

Needs to be adjusted with your installed brew version of RabbitMQ.

Martin54
  • 1,349
  • 2
  • 13
  • 34
René Pardon
  • 187
  • 4
  • 12
  • This didn't work for me. ```pecl config-set php_ini /usr/local/etc/php/7.2/php.ini``` and brew install rabbitmq-c and pecl install amqp it still can't find amqp.so – TDawg Mar 02 '20 at 15:29
0

On my M1 Mac Pro, PHP 8.2.1 the PECL install amqp rabbbitmq path it wanted is /opt/homebrew/Cellar/rabbitmq-c/0.11.0/

Hope this helps someone.

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Kishen Nagaraju Mar 01 '23 at 14:45