Skip to content

Instantly share code, notes, and snippets.

@wcomnisky
Last active October 27, 2023 12:16
Show Gist options
  • Star 18 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save wcomnisky/6d276a9894a5b2078b552cc492fa1abd to your computer and use it in GitHub Desktop.
Save wcomnisky/6d276a9894a5b2078b552cc492fa1abd to your computer and use it in GitHub Desktop.
Install PHP AMQp on MacOS
#!/bin/bash
brew search librabbitmq
brew install rabbitmq-c
pecl install amqp
# set the path to librabbitmq install prefix [autodetect] : /usr/local/Cellar/rabbitmq-c/0.10.0
# if it fails follow the following (reference: https://github.com/pdezwart/php-amqp/issues/355#issuecomment-563203121):
git clone https://github.com/pdezwart/php-amqp.git github-pdezwart-php-amqp/
cd github-pdezwart-php-amqp
#git checkout tags/v1.9.4 ./
sudo phpize
./configure --with-librabbitmq-dir=/usr/local/Cellar/rabbitmq-c/0.10.0
make && make install
# Then you just add extension=amqp to your php.ini, restart your php service
php -i|grep amqp
@Herz3h
Copy link

Herz3h commented Dec 23, 2020

ty I had to specify the autodetect path for it to build :)

@Heavytik
Copy link

Heavytik commented Jan 8, 2021

That succeed, but make test fails (71% tests)??

@Herz3h
Copy link

Herz3h commented Jan 8, 2021

@Heavytik hard to give any help without build logs, you should paste around where it fails with error message

@Heavytik
Copy link

Heavytik commented Jan 8, 2021

There is allways result "Fatal error: Uncaught AMQPConnectionException: Socket error: could not connect to host."
Maybe I am missing some configuration for tests. Build succeed, so I will try to use extension. Maybe I know more later.

@Daisuke-sama
Copy link

There is allways result "Fatal error: Uncaught AMQPConnectionException: Socket error: could not connect to host."
Maybe I am missing some configuration for tests. Build succeed, so I will try to use extension. Maybe I know more later.

If you are running under PHP 7.4.13 then it should work. It doesn't for me on PHP 8.0

@dinke
Copy link

dinke commented Mar 9, 2021

Unfortunately, I am getting an error when doing make && make install (php 8.0.3):

Dinkes-MacBook-Pro:github-pdezwart-php-amqp dinke$ make && make install
/bin/sh /Users/dinke/github-pdezwart-php-amqp/libtool --mode=compile cc -I. -I/Users/dinke/github-pdezwart-php-amqp -I/Users/dinke/github-pdezwart-php-amqp/include -I/Users/dinke/github-pdezwart-php-amqp/main -I/Users/dinke/github-pdezwart-php-amqp -I/usr/local/Cellar/php/8.0.3/include/php -I/usr/local/Cellar/php/8.0.3/include/php/main -I/usr/local/Cellar/php/8.0.3/include/php/TSRM -I/usr/local/Cellar/php/8.0.3/include/php/Zend -I/usr/local/Cellar/php/8.0.3/include/php/ext -I/usr/local/Cellar/php/8.0.3/include/php/ext/date/lib -I/usr/local/Cellar/rabbitmq-c/0.10.0//include -DHAVE_CONFIG_H -g -O2 -c /Users/dinke/github-pdezwart-php-amqp/amqp.c -o amqp.lo
mkdir .libs
cc -I. -I/Users/dinke/github-pdezwart-php-amqp -I/Users/dinke/github-pdezwart-php-amqp/include -I/Users/dinke/github-pdezwart-php-amqp/main -I/Users/dinke/github-pdezwart-php-amqp -I/usr/local/Cellar/php/8.0.3/include/php -I/usr/local/Cellar/php/8.0.3/include/php/main -I/usr/local/Cellar/php/8.0.3/include/php/TSRM -I/usr/local/Cellar/php/8.0.3/include/php/Zend -I/usr/local/Cellar/php/8.0.3/include/php/ext -I/usr/local/Cellar/php/8.0.3/include/php/ext/date/lib -I/usr/local/Cellar/rabbitmq-c/0.10.0//include -DHAVE_CONFIG_H -g -O2 -c /Users/dinke/github-pdezwart-php-amqp/amqp.c -fno-common -DPIC -o .libs/amqp.o
In file included from /Users/dinke/github-pdezwart-php-amqp/amqp.c:27:
In file included from /usr/local/Cellar/php/8.0.3/include/php/main/php.h:31:
In file included from /usr/local/Cellar/php/8.0.3/include/php/Zend/zend.h:357:
/usr/local/Cellar/php/8.0.3/include/php/Zend/zend_operators.h:541:10: error: 'asm goto' constructs are not supported yet
asm goto(
^
/usr/local/Cellar/php/8.0.3/include/php/Zend/zend_operators.h:604:10: error: 'asm goto' constructs are not supported yet
asm goto(
^
/usr/local/Cellar/php/8.0.3/include/php/Zend/zend_operators.h:674:10: error: 'asm goto' constructs are not supported yet
asm goto(
^
/usr/local/Cellar/php/8.0.3/include/php/Zend/zend_operators.h:784:10: error: 'asm goto' constructs are not supported yet
asm goto(
^
4 errors generated.
make: *** [amqp.lo] Error 1
Dinkes-MacBook-Pro:github-pdezwart-php-amqp dinke$

(also tried checking out to tags/v1.9.4, result is the same).

@GuiEloiSantos
Copy link

Hey man, try pecl install amqp-1.11.0beta

I think this issue is related to: php-amqp/php-amqp#386

With amqp not having php 8 support

@Sturm
Copy link

Sturm commented Sep 15, 2021

Hey man, try pecl install amqp-1.11.0beta

I think this issue is related to: php-amqp/php-amqp#386

With amqp not having php 8 support

Huge shoutout to you, works well on MacOS with PHP 8 :)

@smilesrg
Copy link

smilesrg commented Oct 20, 2021

Thanks, @GuiEloiSantos your solution worked for me!

@samyrrakoto
Copy link

Thank you very much, it really help :)

@bahadir-birsoz-bigbrolis
Copy link

bahadir-birsoz-bigbrolis commented May 9, 2022

Update to the answer. amqp 1.11.0 is stable as of 2021/12. Also brew now installs 0.11.0. So the script is outdated.

pecl install amqp works fine on my env (macos, arm, php 8.1).

Has to specify /opt/homebrew/Cellar/rabbitmq-c/0.11.0 during the installation. Autodetect didn't work :

Set the path to librabbitmq install prefix [autodetect] :                         	
building in /private/tmp/pear/temp/pear-build-bahadir.birsozEbcVbL/amqp-1.11.0

// ...

ERROR: `/private/tmp/pear/temp/amqp/configure --with-php-config=/opt/homebrew/opt/php/bin/php-config --with-librabbitmq-dir' failed
Set the path to librabbitmq install prefix [autodetect] : /opt/homebrew/Cellar/rabbitmq-c/0.11.0
building in /private/tmp/pear/temp/pear-build-bahadir.birsozGWZ225/amqp-1.11.0
running: /private/tmp/pear/temp/amqp/configure --with-php-config=/opt/homebrew/opt/php/bin/php-config --with-librabbitmq-dir=/opt/homebrew/Cellar/rabbitmq-c/0.11.0

// ...

Build process completed successfully
Installing '/opt/homebrew/Cellar/php/8.1.5/pecl/20210902/amqp.so'
install ok: channel://pecl.php.net/amqp-1.11.0
Extension amqp enabled in php.ini

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment