The PHP AMQP extension provides PHP functions for communicating with AMQP-compatible servers, such as RabbitMQ.
The AMQP extension does not yet support PHP 7.3 or 7.4.
To install the PHP AMQP extension, SSH in to your server as root and first run the following commands:
sudo apt-get -y install gcc make autoconf libc-dev pkg-config sudo apt-get -y install libssl-dev sudo apt-get -y install librabbitmq-dev
Next, run the following command:
sudo peclX.Y-sp install amqp
When you receive this prompt:
Set the path to librabbitmq install prefix [autodetect] :
press Enter without entering a prefix. This allows the library's location to be autodetected.
Once installed, create a configuration file for the extension and restart PHP by running the following command as root:
sudo bash -c "echo extension=amqp.so > /etc/phpX.Y-sp/conf.d/amqp.ini" sudo service phpX.Y-fpm-sp restart
You can verify the AMQP extension is installed by running this command:
phpX.Y-sp -i | grep -i amqp
You should see output similar to the following:
Additional .ini files parsed => /etc/php7.1-sp/conf.d/amqp.ini, amqp AMQP protocol version => 0-9-1 amqp.auto_ack => 0 => 0 amqp.channel_max => 256 => 256 amqp.connect_timeout => 0 => 0 amqp.frame_max => 131072 => 131072 amqp.heartbeat => 0 => 0 amqp.host => localhost => localhost amqp.login => guest => guest amqp.password => guest => guest amqp.port => 5672 => 5672 amqp.prefetch_count => 3 => 3 amqp.read_timeout => 0 => 0 amqp.timeout => no value => no value amqp.vhost => / => / amqp.write_timeout => 0 => 0
To uninstall this extension, as root run the commands:
sudo rm /etc/phpX.Y-sp/conf.d/amqp.ini sudo peclX.Y-sp uninstall amqp
Next, restart PHP-FPM with the command:
sudo service phpX.Y-fpm-sp restart