Skip to content

Instantly share code, notes, and snippets.

@wcomnisky
Last active November 4, 2024 13:32
Show Gist options
  • 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
@Nek-
Copy link

Nek- commented Nov 4, 2024

As people already say, pecl do not detect correctly the install folder of rabbitmq-c.

The following couple of commands worked for me:

brew install rabbitmq-c 
pecl install amqp
downloading amqp-2.1.2.tgz ...
Starting to download amqp-2.1.2.tgz (118,454 bytes)
..........................done: 118,454 bytes
31 source files, building
running: phpize
Configuring for:
PHP Api Version:         20230831
Zend Module Api No:      20230831
Zend Extension Api No:   420230831
Set the path to librabbitmq install prefix [autodetect] : /opt/homebrew/Cellar/rabbitmq-c/0.14.0/

It ends well with :

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

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